File openstack-quantum.spec of Package openstack-quantum

#
# spec file for package openstack-quantum
#
# Copyright (c) 2014 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:        2013.1.5.a15.g111a6af
Release:        0
Summary:        OpenStack Network
License:        Apache-2.0
Group:          System/Management
Url:            https://launchpad.net/quantum
Source:         neutron-stable-grizzly.tar.gz
Source1:        openstack-%{component}.init
Source2:        %{name}.logrotate
Source3:        quantum-sudoers
Source4:        openstack-%{component}-plugin.init
Source5:        sysconfig.quantum
# PATCH-FIX-OPENSUSE: saschpe@suse.de -- Our testing state path is "/var/lib/openstack-quantum-test", not %%python_sitelib
Patch0:         quantum-test-default-state-path.patch
Patch2:         quantum-suse-config-defaults.diff
# PATCH-FEATURE-UPSTREAM vuntz@suse.com ssl-support.patch -- Backport SSL support from Havana
Patch4:         ssl-support.patch
Patch5:         make-quantum-ns-metadata-proxy-configurable.patch
# PATCH-FIX-UPSTREAM: rhafer@suse.de -- lp#1218556 Avoid race with udev during ovs agent startup
Patch6:         fix-ovs-agent-udev-race.patch
# PATCH-FIX-UPSTREAM vuntz@suse.com neutron-hyperv-wmi2.patch -- Make quantum work for Windows 2012 R2
Patch7:         neutron-hyperv-wmi2.patch
Patch8:         0001-Only-enable-IP6Tables-managing-if-IPv6-is-available.patch
# PATCH-FIX-UPSTREAM https://review.openstack.org/#/c/83394/ rejected because of EOL
Patch9:         bug-869570_CVE-2014-0056-stable-grizzly.patch
BuildRequires:  fdupes
BuildRequires:  openstack-suse-macros
BuildRequires:  openstack-suse-sudo
BuildRequires:  openstack-utils
BuildRequires:  python-devel
BuildRequires:  python-distribute
# Documentation build requirements:
BuildRequires:  python-Sphinx
Requires:       logrotate
Requires:       openstack-suse-sudo
Requires:       python >= 2.6.8
Requires:       python-oslo.config >= 1.1.0
Requires:       python-quantum = %{version}
%if 0%{?suse_version} > 1110
Requires(pre):  pwdutils
%else
Requires(pre):  shadow-utils
%endif
%if 0%{?fedora}
Requires(pre):  shadow-utils
%endif
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
PreReq:         %fillup_prereq

%description
Quantum is a virtual network service for Openstack.

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)

%package -n python-quantum
Summary:        OpenStack Network - Python module
Group:          Development/Languages/Python
Requires:       python >= 2.6.8
Requires:       python-Paste
Requires:       python-PasteDeploy >= 1.5.0
Requires:       python-Routes >= 1.12.3
Requires:       python-SQLAlchemy >= 0.7.8
Requires:       python-WebOb >= 1.2
Requires:       python-alembic >= 0.4.1
Requires:       python-alembic >= 0.4.1
Requires:       python-amqplib >= 0.6.1
Requires:       python-anyjson >= 0.2.4
Requires:       python-argparse
Requires:       python-configobj
Requires:       python-eventlet >= 0.9.17
Requires:       python-extras
Requires:       python-greenlet >= 0.3.1
Requires:       python-httplib2
Requires:       python-iso8601 >= 0.1.4
Requires:       python-keystoneclient >= 0.2.0
Requires:       python-kombu >= 1.0.4
Requires:       python-netaddr
Requires:       python-novaclient
Requires:       python-pyudev
Requires:       python-quantumclient >= 2.2.0

%description -n python-quantum
This package contains the core Python module of OpenStack Quantum.

%package server
Summary:        OpenStack Network - Python module
Group:          Development/Languages/Python
PreReq:         %name = %version
Requires:       python >= 2.6.8

%description server
This package provides the Quantum server

%package dhcp-agent
Summary:        OpenStack Network - DHCP Agent
Group:          Development/Languages/Python
PreReq:         %name = %version
Requires:       dnsmasq
Requires:       python >= 2.6.8

%description dhcp-agent
This package provides the DHCP Agent.

%package l3-agent
Summary:        OpenStack Network - L3 Agent
Group:          Development/Languages/Python
PreReq:         %name = %version
Requires:       python >= 2.6.8

%description l3-agent
This package provides the L3 Agent.

%package lbaas-agent
Summary:        OpenStack Network - Load Balancing Agent
Group:          Development/Languages/Python
PreReq:         %name = %version
Requires:       python >= 2.6.8

%description lbaas-agent
This package provides the Load Balancing as a Service Agent.


%package linuxbridge-agent
Summary:        OpenStack Network - Linux Bridge Agent
Group:          Development/Languages/Python
Provides:       openstack-quantum-agent = %version
PreReq:         %name = %version
Requires:       python >= 2.6.8

%description linuxbridge-agent
This package provides the Linu xBridge Agent.

%package metadata-agent
Summary:        OpenStack Network - Meta Data Agent
Group:          Development/Languages/Python
PreReq:         %name = %version
Requires:       python >= 2.6.8

%description metadata-agent
This package provides the Meta Data Agent.

%package nec-agent
Summary:        OpenStack Network - NEC Agent
Group:          Development/Languages/Python
PreReq:         %name = %version
Provides:       openstack-quantum-agent = %version
Requires:       python >= 2.6.8

%description nec-agent
This package provides the NEC Agent.

%package ryu-agent
Summary:        OpenStack Network - ryu Agent
Group:          Development/Languages/Python
Provides:       openstack-quantum-agent = %version
PreReq:         %name = %version
Requires:       python >= 2.6.8

%description ryu-agent
This package provides the ryu Agent.

%package openvswitch-agent
Summary:        OpenStack Network - Open vSwitch
Group:          Development/Languages/Python
Provides:       openstack-quantum-agent = %version
PreReq:         %name = %version
Requires:       openvswitch
Requires:       python >= 2.6.8

%description openvswitch-agent
This package provides the OpenVSwitch Agent.

%package plugin-cisco
Summary:        OpenStack Network - Cisco Plugin (openvswitch based)
Group:          Development/Languages/Python
Provides:       openstack-quantum-plugin-cisco = %version
PreReq:         %name = %version
PreReq:         %name-server = %version
Requires:       openvswitch
Requires:       python >= 2.6.8
Requires:       python-configobj
Requires:       python-ncclient

%description plugin-cisco
This package provides cisco plugin for OpenStack Network server.

%package test
Summary:        OpenStack Network - Testsuite
Group:          Development/Languages/Python
Requires:       %{name} = %{version}
Requires:       python-WebTest >= 1.3.3
Requires:       python-cliff >= 1.3.1
Requires:       python-configobj
Requires:       python-coverage
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       python-discover
%endif
Requires:       python-fixtures >= 0.3.12
Requires:       python-mock >= 1.0b1
Requires:       python-mox >= 0.5.3
Requires:       python-netifaces
Requires:       python-nose
Requires:       python-nosehtmloutput
Requires:       python-nosexcover
Requires:       python-openstack.nose_plugin
Requires:       python-pep8 >= 1.3.3
Requires:       python-python-subunit
Requires:       python-routes >= 1.12.3
Requires:       python-testrepository >= 0.0.13
Requires:       python-testtools >= 0.9.27
Requires:       python-unittest2

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

%prep
%setup -q -n quantum-2013.1.5.a15.g111a6af
%openstack_cleanup_prep
%patch0
%patch2
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8
%patch9 -p1

%build
python setup.py build
python setup.py build_sphinx -b man

%install
python setup.py install --skip-build --prefix=%{_prefix} --root=%{buildroot} --install-data=/

### directories
install -d -m 755 %{buildroot}%{_localstatedir}/run/quantum
install -d -m 755 %{buildroot}%{_localstatedir}/log/quantum
install -d -m 755 %{buildroot}%{_localstatedir}/lib/quantum

### configuration files
# all needed files are installed automatically
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}

### init scripts
rm %{buildroot}%{_initddir}/quantum-server
install -p -D -m 755 %{SOURCE1} %{buildroot}%{_initddir}/%{name}
mkdir -p %{buildroot}%{_sbindir}
ln -s ../..%{_initddir}/%{name} %{buildroot}%{_sbindir}/rc%{name}

agents=(\
     l3-agent \
     lbaas-agent \
     dhcp-agent \
     openvswitch-agent \
     linuxbridge-agent \
     metadata-agent \
)
agentPaths=(
     /etc/quantum/l3_agent.ini \
     /etc/quantum/lbaas_agent.ini \
     /etc/quantum/dhcp_agent.ini  \
     /etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini \
     /etc/quantum/plugins/linuxbridge/linuxbridge_conf.ini \
     /etc/quantum/metadata_agent.ini \
)

for i in ${!agents[@]} ; do
  install -D -m 755 %{SOURCE4} %{buildroot}%{_initddir}/%{name}-${agents[$i]}
  sed -i -e "s,__NAME__,${agents[$i]},g" %{buildroot}%{_initddir}/%{name}-${agents[$i]}
  if [ ! -z ${agentPaths[$i]} ] ; then
    sed -i -e "s,__PLUGIN_CONFFILE__,${agentPaths[$i]},g" %{buildroot}%{_initddir}/%{name}-${agents[$i]}
  else
    sed -i -e "s,__PLUGIN_CONFFILE__,,g" %{buildroot}%{_initddir}/%{name}-${agents[$i]}
  fi
  ln -s ../..%{_initddir}/%{name}-${agents[$i]} %{buildroot}%{_sbindir}/rc%{name}-${agents[$i]}
done

### sudoers configuration for nova-rootwrap:
install -D -m 440 %{SOURCE3} %{buildroot}%{_sysconfdir}/sudoers.d/openstack-quantum

### documentation
install -d %{buildroot}%{_mandir}/man1
install -m 644 doc/build/man/*.1 %{buildroot}%{_mandir}/man1

## SUSE configuration defaults
openstack-config --set %{buildroot}/etc/quantum/quantum.conf DEFAULT core_plugin quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2
openstack-config --set %{buildroot}/etc/quantum/quantum.conf DEFAULT root_helper "sudo quantum-rootwrap /etc/quantum/rootwrap.conf"
openstack-config --set %{buildroot}/etc/quantum/quantum.conf DEFAULT log_dir /var/log/quantum
openstack-config --set %{buildroot}/etc/quantum/l3_agent.ini DEFAULT external_network_bridge ""

### test subpackage
%openstack_test_package_install
%fdupes %{buildroot}%{_localstatedir}/lib/%{name}-test

#TODO/FIXME: there's an upstream discussion on how to install these,
# it's related to setuptools_git / MANIFEST.in issues.
for i in quantum/tests/unit/nicira/etc/* \
         quantum/tests/etc/rootwrap.d/quantum.test.filters \
         quantum/tests/etc/api-paste.ini.test \
         quantum/plugins/cisco/tests/unit/v2/api-paste.ini.cisco.test \
         quantum/plugins/cisco/tests/unit/v2/quantumv2.conf.cisco.test \
         quantum/plugins/cisco/tests/unit/quantum.conf.cisco.test \
         quantum/plugins/cisco/tests/unit/api-paste.ini.cisco.test \
         quantum/plugins/openvswitch/agent/ovs-quantum-agent-xs_xcp.spec \
         quantum/plugins/openvswitch/agent/xenserver_install.sh \
         quantum/tests/etc/quantum.conf.test \
         quantum/tests/var/*.{crt,key} ; do
    install -D $i %{buildroot}%{python_sitelib}/$i
done

### sysconfig

install -d -m 755 %{buildroot}/var/adm/fillup-templates
install -m 644 %{S:5} %{buildroot}/var/adm/fillup-templates

### misc
%fdupes %{buildroot}%{python_sitelib}/%{component}

### authentication cache dir
mkdir -p %{buildroot}%{_localstatedir}/cache/quantum

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

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

%preun server
%stop_on_removal openstack-quantum

%postun server
%restart_on_update openstack-quantum
%insserv_cleanup

%post
%{fillup_only -n quantum}

%files
%defattr(-,root,root,-)
%doc LICENSE README
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config %{_sysconfdir}/sudoers.d/openstack-quantum
%dir %{_sysconfdir}/quantum
%config(noreplace) %{_sysconfdir}/quantum/api-paste.ini
%config %{_sysconfdir}/quantum/policy.json
%config(noreplace) %attr(0640, root, %{groupname}) %{_sysconfdir}/quantum/quantum.conf
%config %{_sysconfdir}/quantum/rootwrap.conf
%dir %{_sysconfdir}/quantum/rootwrap.d/
%ghost %dir %attr(0755, %{username}, root) %{_localstatedir}/run/quantum
%dir %attr(0755, %{username}, root) %{_localstatedir}/lib/quantum
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/cache/quantum
%dir %attr(0755, %{username}, %{groupname}) %{_localstatedir}/log/quantum
%dir %{_sysconfdir}/quantum/plugins
%dir %{_sysconfdir}/quantum/plugins/bigswitch/
%dir %{_sysconfdir}/quantum/plugins/brocade/
%dir %{_sysconfdir}/quantum/plugins/hyperv/
%dir %{_sysconfdir}/quantum/plugins/metaplugin/
%dir %{_sysconfdir}/quantum/plugins/midonet
%dir %{_sysconfdir}/quantum/plugins/nec/
%dir %{_sysconfdir}/quantum/plugins/nicira/
%dir %{_sysconfdir}/quantum/plugins/plumgrid/
%dir %{_sysconfdir}/quantum/plugins/ryu/
%config(noreplace) %{_sysconfdir}/quantum/plugins/bigswitch/restproxy.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/hyperv/hyperv_quantum_plugin.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/linuxbridge/linuxbridge_conf.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/metaplugin/metaplugin.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/midonet/midonet.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/nec/nec.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/nicira/nvp.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/brocade/brocade.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/plumgrid/plumgrid.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/openvswitch/ovs_quantum_plugin.ini
%config(noreplace) %{_sysconfdir}/quantum/plugins/ryu/ryu.ini
%config %{_sysconfdir}/quantum/rootwrap.d/iptables-firewall.filters
%{_bindir}/quantum-debug
%{_bindir}/quantum-check-nvp-config
%{_bindir}/quantum-netns-cleanup
%{_bindir}/quantum-ns-metadata-proxy
%{_bindir}/quantum-rootwrap
%{_mandir}/man1/quantum-server.1%{?ext_man}
/var/adm/fillup-templates/sysconfig.quantum

%files dhcp-agent
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/quantum-dhcp-agent
%{_bindir}/quantum-dhcp-agent-dnsmasq-lease-update
%{_initddir}/openstack-quantum-dhcp-agent
%{_sbindir}/rcopenstack-quantum-dhcp-agent
%config(noreplace) %{_sysconfdir}/quantum/dhcp_agent.ini
%config %{_sysconfdir}/quantum/rootwrap.d/dhcp.filters

%files l3-agent
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/quantum-l3-agent
%config %{_sysconfdir}/quantum/rootwrap.d/l3.filters
%config(noreplace) %{_sysconfdir}/quantum/l3_agent.ini
%{_initddir}/openstack-quantum-l3-agent
%{_sbindir}/rcopenstack-quantum-l3-agent

%files lbaas-agent
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/quantum-lbaas-agent
%config %{_sysconfdir}/quantum/rootwrap.d/lbaas-haproxy.filters
%config(noreplace) %{_sysconfdir}/quantum/lbaas_agent.ini
%{_initddir}/openstack-quantum-lbaas-agent
%{_sbindir}/rcopenstack-quantum-lbaas-agent

%files metadata-agent
%defattr(-,root,root,-)
%doc LICENSE
%config(noreplace) %{_sysconfdir}/quantum/metadata_agent.ini
%{_bindir}/quantum-metadata-agent
%{_initddir}/openstack-quantum-metadata-agent
%{_sbindir}/rcopenstack-quantum-metadata-agent

%files nec-agent
%defattr(-,root,root,-)
%doc LICENSE
%config %{_sysconfdir}/quantum/rootwrap.d/nec-plugin.filters
%{_bindir}/quantum-nec-agent

%files ryu-agent
%defattr(-,root,root,-)
%doc LICENSE
%config %{_sysconfdir}/quantum/rootwrap.d/ryu-plugin.filters
%{_bindir}/quantum-ryu-agent

%files linuxbridge-agent
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/quantum-linuxbridge-agent
%config %{_sysconfdir}/quantum/rootwrap.d/linuxbridge-plugin.filters
%dir %{_sysconfdir}/quantum/plugins/linuxbridge/
%{_initddir}/openstack-quantum-linuxbridge-agent
%{_sbindir}/rcopenstack-quantum-linuxbridge-agent

%files openvswitch-agent
%defattr(-,root,root,-)
%doc LICENSE
%dir %{_sysconfdir}/quantum/plugins/openvswitch/
%{_bindir}/quantum-openvswitch-agent
%{_bindir}/quantum-ovs-cleanup
%config %{_sysconfdir}/quantum/rootwrap.d/openvswitch-plugin.filters
%{_initddir}/openstack-quantum-openvswitch-agent
%{_sbindir}/rcopenstack-quantum-openvswitch-agent

%files server
%defattr(-,root,root,-)
%doc LICENSE
%{_bindir}/quantum-server
%{_bindir}/quantum-db-manage
%{_initddir}/openstack-quantum
%{_sbindir}/rcopenstack-quantum

%files -n python-quantum
%defattr(-,root,root,-)
%doc LICENSE
%{python_sitelib}/%{component}/
%{python_sitelib}/%{component}-*.egg-info
# Part of test subpackage
%exclude %{python_sitelib}/%{component}/tests/

%files plugin-cisco
%defattr(-,root,root)
%dir %{_sysconfdir}/%{component}/plugins/cisco/
%config(noreplace) %{_sysconfdir}/%{component}/plugins/cisco/cisco_plugins.ini
%config(noreplace) %{_sysconfdir}/%{component}/plugins/cisco/credentials.ini
%config(noreplace) %{_sysconfdir}/%{component}/plugins/cisco/db_conn.ini
%config(noreplace) %{_sysconfdir}/%{component}/plugins/cisco/l2network_plugin.ini
%config(noreplace) %{_sysconfdir}/%{component}/plugins/cisco/nexus.ini

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

%changelog
openSUSE Build Service is sponsored by