File openstack-quantum.spec of Package openstack-quantum

#
# spec file for package openstack-quantum
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define component quantum
%define groupname openstack-%{component}
%define username openstack-%{component}

Name:           openstack-%{component}
Version:        2012.1+git.1342368520.753730a
Release:        0
Summary:        OpenStack Virtual Network Service (Quantum)
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/quantum
Source:         %{component}-%{version}.tar.gz
Source1:        openstack-quantum.init
Source2:        %{name}.logrotate
BuildRequires:  fdupes
BuildRequires:  python-devel
BuildRequires:  python-setuptools
Requires:       logrotate
Requires:       python >= 2.6.8
Requires:       python-eventlet
Requires:       python-lxml
Requires:       python-quantumclient
Requires:       python-routes
Requires:       python-webob

Requires(pre):  pwdutils
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%py_requires
%else
BuildArch:      noarch
%endif

%description
Quantum is a virtual network service for Openstack, and a part of
Netstack.

Just like OpenStack Nova provides an API to dynamically request and
configure virtual servers, Quantum provides an API to dynamically
request and configure virtual networks. These networks connect
"interfaces" from other OpenStack services (e.g., vNICs from Nova VMs).
The Quantum API supports extensions to provide advanced network
capabilities (e.g., QoS, ACLs, network monitoring, etc)

Quantum is an officially incubated OpenStack project.

%package test
Summary:        OpenStack Virtual Network Service (Quantum) - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python-nose

%description test
The OpenStack Quantum testsuite. It is used to verify the functionality
of OpenStack Quantum.

%prep
%setup -q -n %{component}-%{version}

%build
python setup.py build

%install
python setup.py install --skip-build --root=%{buildroot} \
    --install-purelib=%{python_sitelib} --install-scripts=%{_bindir} --prefix=''

# remove un-needed, mostly empty directories
# TODO: fix this upstream
rm -r %{buildroot}%{python_sitelib}/bin
rm -r %{buildroot}%{python_sitelib}/doc
rm -r %{buildroot}%{python_sitelib}/tools

# PID and log dirs
install -d -m 755 %{buildroot}%{_localstatedir}/run/quantum
install -d -m 755 %{buildroot}%{_localstatedir}/log/quantum

install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

# we provide our own initfile
rm %{buildroot}%{_initddir}/quantum-server
install -p -D -m 755 %{SOURCE1} %{buildroot}%{_initddir}/openstack-quantum

# SUSE-policy symlink
mkdir -p %{buildroot}%{_sbindir}
pushd %{buildroot}
  ln -s %{_initddir}/openstack-quantum ./%{_sbindir}/rcopenstack-quantum
popd

# for test sub-package
install -d -m 755 %{buildroot}%{_localstatedir}/lib/openstack-quantum-test
mv run_tests* %{buildroot}%{_localstatedir}/lib/openstack-quantum-test/

%pre
getent group %{groupname} > /dev/null || groupadd -r %{groupname}
getent passwd %{username} > /dev/null || \
    useradd -r -g %{groupname} -d %{_localstatedir}/lib/nova -s /sbin/nologin \
    -c "Openstack Quantum Daemons" %{username}
exit 0

%post
%{fillup_and_insserv -f openstack-quantum}
%restart_on_update openstack-quantum

%preun
%stop_on_removal openstack-quantum

%postun
%insserv_cleanup

%files
%defattr(-,root,root,-)
%{_bindir}/quantum*
%{_sbindir}/rcopenstack-quantum
%{_initddir}/openstack-quantum
%dir %{_sysconfdir}/quantum
%config(noreplace) %{_sysconfdir}/quantum/plugins.ini
%config(noreplace) %{_sysconfdir}/quantum/quantum.conf
%dir %{_sysconfdir}/quantum/plugins
%dir %{_sysconfdir}/quantum/plugins/cisco/
%dir %{_sysconfdir}/quantum/plugins/linuxbridge/
%dir %{_sysconfdir}/quantum/plugins/nicira/
%dir %{_sysconfdir}/quantum/plugins/openvswitch/
%dir %{_sysconfdir}/quantum/plugins/ryu/
%config(noreplace) %{_sysconfdir}/quantum/plugins/*/*.ini
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/run/quantum
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/log/quantum
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%dir %{python_sitelib}/%{component}
%{python_sitelib}/%{component}/api
%{python_sitelib}/%{component}/db
%{python_sitelib}/%{component}/extensions
%{python_sitelib}/%{component}/plugins
%{python_sitelib}/%{component}/openstack
%{python_sitelib}/%{component}/server
%{python_sitelib}/%{component}/rootwrap
%{python_sitelib}/%{component}/*pyc
%{python_sitelib}/%{component}/*py
%{python_sitelib}/%{component}-*.egg-info

%files test
%defattr(-,root,root)
%{python_sitelib}/%{component}/tests
%{_localstatedir}/lib/%{name}-test
%{_sysconfdir}/%{component}/quantum.conf.test

%changelog
openSUSE Build Service is sponsored by