File openstack-neutron.spec of Package openstack-neutron

#
# spec file for package openstack-neutron
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%global with_doc 1
%global sname neutron
%if 0%{?rhel} || 0%{?fedora}
%global rdo 1
%endif
Name:           openstack-neutron
Version:        13.0.2
Release:        0
Summary:        OpenStack Networking Service
License:        Apache-2.0
Group:          Applications/System
URL:            https://launchpad.net/neutron
Source0:        https://tarballs.openstack.org/%{sname}/%{sname}-13.0.2.tar.gz
Source1:        openstack-neutron.logrotate
Source2:        neutron-sudoers
Source3:        neutron-server.service
Source4:        neutron-linuxbridge-agent.service
Source5:        neutron-openvswitch-agent.service
Source6:        neutron-dhcp-agent.service
Source7:        neutron-l3-agent.service
Source8:        neutron-metadata-agent.service
Source9:        neutron-macvtap-agent.service
Source10:       neutron-metering-agent.service
Source11:       neutron-sriov-nic-agent.service
Source12:       neutron-rpc-server.service
Source13:       neutron-server.defaultconf
Source14:       neutron-server.README.config
Source15:       neutron-enable-bridge-firewall.sh
BuildRequires:  openstack-macros
BuildRequires:  openstack-tempest
BuildRequires:  python-PyMySQL
BuildRequires:  python-WebTest
BuildRequires:  python-ddt
BuildRequires:  python-devel
BuildRequires:  python-fixtures
BuildRequires:  python-mock
BuildRequires:  python-os-testr
BuildRequires:  python-oslotest
BuildRequires:  python-python-subunit
BuildRequires:  python-reno
BuildRequires:  python-testrepository
BuildRequires:  python-testresources
BuildRequires:  python-testtools
BuildRequires:  sudo
Requires:       python-%{sname} = %{version}-%{release}
Requires:       sudo
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  systemd-rpm-macros
%{?systemd_requires}
%else
BuildRequires:  systemd
Requires(post): systemd
Requires(postun): systemd
Requires(preun): systemd
%endif

%description
Neutron is a virtual network service for Openstack.

This package contains the base supporting files.

%package -n     python-%{sname}
Summary:        Neutron Python libraries
Group:          Applications/System
BuildRequires:  python-designateclient
BuildRequires:  python-httplib2
BuildRequires:  python-keystoneauth1
BuildRequires:  python-keystonemiddleware
BuildRequires:  python-neutron-lib
BuildRequires:  python-neutronclient
BuildRequires:  python-novaclient
BuildRequires:  python-os-xenapi
BuildRequires:  python-oslo.cache
BuildRequires:  python-oslo.privsep
BuildRequires:  python-oslo.reports
BuildRequires:  python-oslo.rootwrap
BuildRequires:  python-oslo.versionedobjects
BuildRequires:  python-osprofiler
BuildRequires:  python-ovs
BuildRequires:  python-ovsdbapp
BuildRequires:  python-pecan
BuildRequires:  python-pyroute2
BuildRequires:  python-ryu
BuildRequires:  python-weakrefmethod
Requires:       python-Jinja2
Requires:       python-Paste
Requires:       python-PasteDeploy
Requires:       python-Routes
Requires:       python-SQLAlchemy
Requires:       python-WebOb
Requires:       python-alembic
Requires:       python-debtcollector
Requires:       python-designateclient
Requires:       python-eventlet
Requires:       python-httplib2
Requires:       python-keystoneauth1
Requires:       python-keystonemiddleware
Requires:       python-netaddr
Requires:       python-netifaces
Requires:       python-neutron-lib
Requires:       python-neutronclient
Requires:       python-novaclient
Requires:       python-os-xenapi
Requires:       python-oslo.cache
Requires:       python-oslo.concurrency
Requires:       python-oslo.config
Requires:       python-oslo.context
Requires:       python-oslo.db
Requires:       python-oslo.i18n
Requires:       python-oslo.log
Requires:       python-oslo.messaging
Requires:       python-oslo.middleware
Requires:       python-oslo.policy
Requires:       python-oslo.privsep
Requires:       python-oslo.reports
Requires:       python-oslo.rootwrap
Requires:       python-oslo.serialization
Requires:       python-oslo.service
Requires:       python-oslo.utils
Requires:       python-oslo.versionedobjects
Requires:       python-osprofiler
Requires:       python-ovs
Requires:       python-ovsdbapp
Requires:       python-pbr
Requires:       python-pecan
Requires:       python-psutil
Requires:       python-pyroute2
Requires:       python-requests
Requires:       python-ryu
Requires:       python-six
Requires:       python-stevedore
Requires:       python-tenacity
Requires:       python-weakrefmethod

%description -n   python-%{sname}
Neutron is a virtual network service for Openstack.

This package contains the Neutron Python library.

%package api
Summary:        Neutron API server
Group:          Applications/System
Requires:       openstack-%{sname} = %{version}-%{release}

%description api
Neutron is a virtual network service for Openstack.

This package contains the Neutron API server.

%package linuxbridge
Summary:        Neutron Linuxbridge agent
Group:          Applications/System
Requires:       /sbin/modprobe
Requires:       bridge-utils
Requires:       ebtables
Requires:       ipset
Requires:       iptables
Requires:       openstack-%{sname} = %{version}-%{release}

%description linuxbridge
Neutron is a virtual network service for Openstack.

This package contains the Neutron agent that implements virtual
networks using VLAN or VXLAN using Linuxbridge technology.

%package macvtap-agent
Summary:        Neutron macvtap agent
Group:          Applications/System
Requires:       openstack-%{sname} = %{version}-%{release}

%description macvtap-agent
Neutron is a virtual network service for Openstack.

This package contains the Neutron agent that implements
macvtap attachments for libvirt qemu/kvm instances.

%package ml2
Summary:        Neutron ML2 plugin
Group:          Applications/System
Requires:       openstack-%{sname} = %{version}-%{release}

%description ml2
Neutron is a virtual network service for Openstack.

This package contains a Neutron plugin that allows the use of drivers
to support separately extensible sets of network types and the mechanisms
for accessing those types.

%package openvswitch
Summary:        Neutron openvswitch plugin
Group:          Applications/System
Requires:       /sbin/modprobe
Requires:       ipset
Requires:       iptables
Requires:       openstack-%{sname} = %{version}-%{release}
Requires:       openvswitch

%description openvswitch
Neutron is a virtual network service for Openstack.

This package contains the Neutron plugin that implements virtual
networks using Open vSwitch.

%package metering-agent
Summary:        Neutron bandwidth metering agent
Group:          Applications/System
Requires:       iptables
Requires:       openstack-%{sname} = %{version}-%{release}

%description metering-agent
Neutron is a virtual network service for Openstack.

This package contains the Neutron agent responsible for generating bandwidth
utilization notifications.

%package rpc-server
Summary:        Neutron (RPC only) Server
Group:          Applications/System
Requires:       openstack-%{sname} = %{version}-%{release}

%description rpc-server
Neutron is a virtual network service for Openstack.

This package contains an alternative Neutron server that handles AMQP RPC
workload only.

%package sriov-nic-agent
Summary:        Neutron SR-IOV NIC agent
Group:          Applications/System
Requires:       openstack-%{sname} = %{version}-%{release}

%description sriov-nic-agent
Neutron is a virtual network service for Openstack.

This package contains the Neutron agent to support advanced features of
SR-IOV network cards.

%if 0%{?with_doc}
%package doc
Summary:        Documentation for OpenStack Networking Service
Group:          Documentation/HTML
BuildRequires:  python-Sphinx
BuildRequires:  python-openstackdocstheme
BuildRequires:  python-oslosphinx

%description doc
OpenStack Neutron documentaion.

This package contains the documentation
%endif

%prep
%autosetup -n %{sname}-13.0.2

%py_req_cleanup
sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg

%build
%py2_build

%if 0%{?with_doc}
# generate html docs
PBR_VERSION=13.0.2 sphinx-build -b html doc/source doc/build/html
# remove the Sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
%endif

# Generate configuration files
PYTHONPATH=. tools/generate_config_file_samples.sh
find etc -name *.sample | while read filename
do
    filedir=$(dirname $filename)
    file=$(basename $filename .sample)
    mv ${filename} ${filedir}/${file}
done

%install
%py2_install

# Move rootwrap files to proper location
install -d -m 755 %{buildroot}%{_datarootdir}/%{sname}/rootwrap
mv %{buildroot}%{_prefix}%{_sysconfdir}/%{sname}/rootwrap.d/*.filters %{buildroot}%{_datarootdir}/%{sname}/rootwrap

# Move config files to proper location
install -d -m 755 %{buildroot}%{_sysconfdir}/%{sname}
mv %{buildroot}%{_prefix}%{_sysconfdir}/%{sname}/* %{buildroot}%{_sysconfdir}/%{sname}
install -p -D -m 640 etc/api-paste.ini %{buildroot}%{_sysconfdir}/%{sname}/api-paste.ini
install -p -D -m 640 etc/policy.json %{buildroot}%{_sysconfdir}/%{sname}/policy.json
install -p -D -m 640 etc/l3_agent.ini %{buildroot}%{_sysconfdir}/%{sname}/l3_agent.ini
install -p -D -m 640 etc/dhcp_agent.ini %{buildroot}%{_sysconfdir}/%{sname}/dhcp_agent.ini
install -p -D -m 640 etc/metadata_agent.ini %{buildroot}%{_sysconfdir}/%{sname}/metadata_agent.ini
install -d -m 755 %{buildroot}%{_sysconfdir}/%{sname}.conf.d
install -D -m 640 %{SOURCE13} %{buildroot}/%{_sysconfdir}/%{sname}/%{sname}.conf.d/010-neutron.conf
install -D -m 440 %{SOURCE14} %{buildroot}/%{_sysconfdir}/%{sname}/README.config

# The generated config files are not moved automatically by setup.py
install -d -m 755 %{buildroot}%{_sysconfdir}/%{sname}/plugins/ml2

mv etc/%{sname}.conf %{buildroot}%{_sysconfdir}/%{sname}/%{sname}.conf
for agent in dhcp l3 metadata metering
do
  mv etc/${agent}_agent.ini %{buildroot}%{_sysconfdir}/%{sname}/${agent}_agent.ini
done

for file in linuxbridge_agent ml2_conf openvswitch_agent sriov_agent
do
  mv etc/%{sname}/plugins/ml2/${file}.ini %{buildroot}%{_sysconfdir}/%{sname}/plugins/ml2/${file}.ini
done

# Install logrotate
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-neutron.logrotate

# Install sudoers
install -p -D -m 440 %{SOURCE2} %{buildroot}%{_sysconfdir}/sudoers.d/%{sname}

# Install systemd units
install -p -D -m 644 %{SOURCE3} %{buildroot}%{_unitdir}/neutron-server.service
install -p -D -m 644 %{SOURCE4} %{buildroot}%{_unitdir}/neutron-linuxbridge-agent.service
install -p -D -m 644 %{SOURCE5} %{buildroot}%{_unitdir}/neutron-openvswitch-agent.service
install -p -D -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/neutron-dhcp-agent.service
install -p -D -m 644 %{SOURCE7} %{buildroot}%{_unitdir}/neutron-l3-agent.service
install -p -D -m 644 %{SOURCE8} %{buildroot}%{_unitdir}/neutron-metadata-agent.service
install -p -D -m 644 %{SOURCE9} %{buildroot}%{_unitdir}/neutron-macvtap-agent.service
install -p -D -m 644 %{SOURCE10} %{buildroot}%{_unitdir}/neutron-metering-agent.service
install -p -D -m 644 %{SOURCE11} %{buildroot}%{_unitdir}/neutron-sriov-nic-agent.service
install -p -D -m 644 %{SOURCE12} %{buildroot}%{_unitdir}/neutron-rpc-server.service

# Install helper scripts
install -p -D -m 755 %{SOURCE15} %{buildroot}%{_bindir}/neutron-enable-bridge-firewall.sh

# Create configuration directories for all services that can be populated by users with custom *.conf files
for service in neutron server rpc-server ovs-cleanup netns-cleanup linuxbridge-cleanup macvtap-agent; do
    mkdir -p %{buildroot}/%{_sysconfdir}/%{sname}/$service.conf.d
done
for service in linuxbridge openvswitch dhcp l3 metadata metering sriov-nic; do
    mkdir -p %{buildroot}/%{_sysconfdir}/%{sname}/$service-agent.conf.d
done

%pre
%openstack_pre_user_group_create neutron neutron
exit 0

%check
# don't want to depend on hacking for package building
rm neutron/tests/unit/hacking/test_checks.py
# FIXME(jpena): Reduce the number of unit tests, we have issues when testing time goes > 1h
# FIXME(dmllr): Currently fail
# OS_TEST_PATH=./neutron/tests/unit ostestr --black-regex '(neutron.tests.unit.objects|neutron.tests.unit.plugins)'

%post
%systemd_post neutron-dhcp-agent.service
%systemd_post neutron-l3-agent.service
%systemd_post neutron-metadata-agent.service

%preun
%systemd_preun neutron-dhcp-agent.service
%systemd_preun neutron-l3-agent.service
%systemd_preun neutron-metadata-agent.service

%postun
%systemd_postun_with_restart neutron-dhcp-agent.service
%systemd_postun_with_restart neutron-l3-agent.service
%systemd_postun_with_restart neutron-metadata-agent.service

%post api
%systemd_post neutron-server.service

%preun api
%systemd_preun neutron-server.service

%postun api
%systemd_postun_with_restart neutron-server.service

%post linuxbridge
%systemd_post neutron-linuxbridge-agent.service

%preun linuxbridge
%systemd_preun neutron-linuxbridge-agent.service

%postun linuxbridge
%systemd_postun_with_restart neutron-linuxbridge-agent.service

%post macvtap-agent
%systemd_post neutron-macvtap-agent.service

%preun macvtap-agent
%systemd_preun neutron-macvtap-agent.service

%postun macvtap-agent
%systemd_postun_with_restart neutron-macvtap-agent.service

%post openvswitch
%systemd_post neutron-openvswitch-agent.service

%preun openvswitch
%systemd_preun neutron-openvswitch-agent.service

%postun openvswitch
%systemd_postun_with_restart neutron-openvswitch-agent.service

%post metering-agent
%systemd_post neutron-metering-agent.service

%preun metering-agent
%systemd_preun neutron-metering-agent.service

%postun metering-agent
%systemd_postun_with_restart neutron-metering-agent.service

%post rpc-server
%systemd_post neutron-rpc-server.service

%preun rpc-server
%systemd_preun neutron-rpc-server.service

%postun rpc-server
%systemd_postun_with_restart neutron-rpc-server.service

%post sriov-nic-agent
%systemd_post neutron-sriov-nic-agent.service

%preun sriov-nic-agent
%systemd_preun neutron-sriov-nic-agent.service

%postun sriov-nic-agent
%systemd_postun_with_restart neutron-sriov-nic-agent.service

%files
%license LICENSE
%{_bindir}/neutron-enable-bridge-firewall.sh
%{_bindir}/neutron-db-manage
%{_bindir}/neutron-debug
%{_bindir}/neutron-dhcp-agent
%{_bindir}/neutron-ipset-cleanup
%{_bindir}/neutron-keepalived-state-change
%{_bindir}/neutron-l3-agent
%{_bindir}/neutron-metadata-agent
%{_bindir}/neutron-netns-cleanup
%{_bindir}/neutron-pd-notify
%{_bindir}/neutron-rootwrap
%{_bindir}/neutron-rootwrap-daemon
%{_bindir}/neutron-rootwrap-xen-dom0
%{_bindir}/neutron-sanity-check
%{_bindir}/neutron-usage-audit
%{_unitdir}/neutron-dhcp-agent.service
%{_unitdir}/neutron-l3-agent.service
%{_unitdir}/neutron-metadata-agent.service
%attr(-, root, %{sname}) %{_sysconfdir}/%{sname}/api-paste.ini
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/dhcp_agent.ini
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/l3_agent.ini
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/metadata_agent.ini
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/policy.json
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/rootwrap.conf
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/%{sname}.conf
%{_sysconfdir}/%{sname}/README.config
%dir %{_sysconfdir}/%{sname}
%dir %{_sysconfdir}/%{sname}/plugins
%dir %{_sysconfdir}/%{sname}/%{sname}.conf.d
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/%{sname}.conf.d/010-neutron.conf
%{_sysconfdir}/sudoers.d/%{sname}
%config(noreplace) %{_sysconfdir}/logrotate.d/*
%dir %{_datarootdir}/%{sname}
%dir %{_datarootdir}/%{sname}/rootwrap
%{_datarootdir}/%{sname}/rootwrap/debug.filters
%{_datarootdir}/%{sname}/rootwrap/dhcp.filters
%{_datarootdir}/%{sname}/rootwrap/dibbler.filters
%{_datarootdir}/%{sname}/rootwrap/ebtables.filters
%{_datarootdir}/%{sname}/rootwrap/ipset-firewall.filters
%{_datarootdir}/%{sname}/rootwrap/iptables-firewall.filters
%{_datarootdir}/%{sname}/rootwrap/l3.filters
%{_datarootdir}/%{sname}/rootwrap/netns-cleanup.filters
%{_datarootdir}/%{sname}/rootwrap/privsep.filters

%files api
%license LICENSE
%{_bindir}/neutron-api
%{_bindir}/neutron-server
%{_unitdir}/neutron-server.service
%dir %{_sysconfdir}/%{sname}/server.conf.d

%files -n python-%{sname}
%defattr(-,root,root,-)
%license LICENSE
%{python2_sitelib}/%{sname}
%{python2_sitelib}/%{sname}-*.egg-info

%if 0%{?with_doc}
%files doc
%license LICENSE
%doc doc/build/html
%endif

%files linuxbridge
%license LICENSE
%{_bindir}/neutron-linuxbridge-agent
%{_bindir}/neutron-linuxbridge-cleanup
%{_unitdir}/neutron-linuxbridge-agent.service
%{_datarootdir}/%{sname}/rootwrap/linuxbridge-plugin.filters
%dir %{_sysconfdir}/%{sname}/plugins/ml2
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/plugins/ml2/linuxbridge_agent.ini
%dir %{_sysconfdir}/%{sname}/linuxbridge-agent.conf.d

%files macvtap-agent
%license LICENSE
%{_bindir}/neutron-macvtap-agent
%{_unitdir}/neutron-macvtap-agent.service
%dir %{_sysconfdir}/%{sname}/macvtap-agent.conf.d

%files ml2
%license LICENSE
%doc %{sname}/plugins/ml2/README
%dir %{_sysconfdir}/%{sname}/plugins/ml2
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/plugins/ml2/*.ini
%exclude %{_sysconfdir}/%{sname}/plugins/ml2/linuxbridge_agent.ini
%exclude %{_sysconfdir}/%{sname}/plugins/ml2/openvswitch_agent.ini
%exclude %{_sysconfdir}/%{sname}/plugins/ml2/sriov_agent.ini

%files openvswitch
%license LICENSE
%{_bindir}/neutron-openvswitch-agent
%{_bindir}/neutron-ovs-cleanup
%{_unitdir}/neutron-openvswitch-agent.service
%{_datarootdir}/%{sname}/rootwrap/openvswitch-plugin.filters
%dir %{_sysconfdir}/%{sname}/plugins/ml2
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/plugins/ml2/openvswitch_agent.ini
%dir %{_sysconfdir}/%{sname}/openvswitch-agent.conf.d

%files metering-agent
%license LICENSE
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/metering_agent.ini
%{_unitdir}/neutron-metering-agent.service
%{_bindir}/neutron-metering-agent
%dir %{_sysconfdir}/%{sname}/metering-agent.conf.d

%files rpc-server
%license LICENSE
%{_bindir}/neutron-rpc-server
%{_unitdir}/neutron-rpc-server.service
%dir %{_sysconfdir}/%{sname}/rpc-server.conf.d

%files sriov-nic-agent
%license LICENSE
%{_unitdir}/neutron-sriov-nic-agent.service
%{_bindir}/neutron-sriov-nic-agent
%config(noreplace) %attr(0640, root, %{sname}) %{_sysconfdir}/%{sname}/plugins/ml2/sriov_agent.ini
%dir %{_sysconfdir}/%{sname}/sriov-nic-agent.conf.d

%changelog
openSUSE Build Service is sponsored by