a845ee71fe30ef7f92c9554da7e7c4a2aceaa868
[gentoo.git] / sys-cluster / neutron / neutron-9.2.0.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 PYTHON_COMPAT=( python2_7 )
6 # still no 34 :( https://bugs.launchpad.net/neutron/+bug/1630439
7
8 inherit distutils-r1 linux-info user
9
10 DESCRIPTION="A virtual network service for Openstack"
11 HOMEPAGE="https://launchpad.net/neutron"
12 SRC_URI="https://dev.gentoo.org/~prometheanfire/dist/openstack/neutron/newton/configs.tar.gz -> neutron-configs-${PV}.tar.gz
13         https://dev.gentoo.org/~prometheanfire/dist/openstack/neutron/newton/ml2_plugins.tar.gz -> neutron-ml2-plugins-${PV}.tar.gz
14         https://tarballs.openstack.org/${PN}/${P}.tar.gz"
15
16 LICENSE="Apache-2.0"
17 SLOT="0"
18 KEYWORDS="amd64 ~arm64 x86"
19 IUSE="compute-only dhcp ipv6 l3 metadata openvswitch linuxbridge server sqlite mysql postgres"
20 REQUIRED_USE="!compute-only? ( || ( mysql postgres sqlite ) )
21                                                 compute-only? ( !mysql !postgres !sqlite !dhcp !l3 !metadata !server
22                                                 || ( openvswitch linuxbridge ) )"
23
24 CDEPEND=">=dev-python/pbr-1.8[${PYTHON_USEDEP}]"
25 DEPEND="
26         dev-python/setuptools[${PYTHON_USEDEP}]
27         ${CDEPEND}
28         app-admin/sudo"
29
30 RDEPEND="
31         ${CDEPEND}
32         dev-python/paste[${PYTHON_USEDEP}]
33         >=dev-python/pastedeploy-1.5.0-r1[${PYTHON_USEDEP}]
34         >=dev-python/routes-1.12.3[${PYTHON_USEDEP}]
35         !~dev-python/routes-2.0[${PYTHON_USEDEP}]
36         !~dev-python/routes-2.1[$(python_gen_usedep 'python2_7')]
37         !~dev-python/routes-2.3[${PYTHON_USEDEP}]
38         >=dev-python/debtcollector-1.2.0[${PYTHON_USEDEP}]
39         >=dev-python/eventlet-0.18.4[${PYTHON_USEDEP}]
40         >=dev-python/pecan-1.0.0[${PYTHON_USEDEP}]
41         !~dev-python/pecan-1.0.2[${PYTHON_USEDEP}]
42         !~dev-python/pecan-1.0.3[${PYTHON_USEDEP}]
43         !~dev-python/pecan-1.0.4[${PYTHON_USEDEP}]
44         >=dev-python/greenlet-0.3.2[${PYTHON_USEDEP}]
45         >=dev-python/httplib2-0.7.5[${PYTHON_USEDEP}]
46         >=dev-python/requests-2.10.0[${PYTHON_USEDEP}]
47         >=dev-python/jinja-2.8[${PYTHON_USEDEP}]
48         >=dev-python/keystonemiddleware-4.0.0[${PYTHON_USEDEP}]
49         !=dev-python/keystonemiddleware-4.1.0[${PYTHON_USEDEP}]
50         !=dev-python/keystonemiddleware-4.5.0[${PYTHON_USEDEP}]
51         >=dev-python/netaddr-0.7.13[${PYTHON_USEDEP}]
52         !~dev-python/netaddr-0.7.16[${PYTHON_USEDEP}]
53         >=dev-python/netifaces-0.10.4[${PYTHON_USEDEP}]
54         >=dev-python/neutron-lib-0.4.0[${PYTHON_USEDEP}]
55         >=dev-python/python-neutronclient-5.1.0[${PYTHON_USEDEP}]
56         >=dev-python/retrying-1.2.3[${PYTHON_USEDEP}]
57         !~dev-python/retrying-1.3.0[${PYTHON_USEDEP}]
58         >=dev-python/ryu-3.30[${PYTHON_USEDEP}]
59         !~dev-python/ryu-4.1[${PYTHON_USEDEP}]
60         !~dev-python/ryu-4.2[${PYTHON_USEDEP}]
61         !~dev-python/ryu-4.2.1[${PYTHON_USEDEP}]
62         !~dev-python/ryu-4.4[${PYTHON_USEDEP}]
63         compute-only? (
64                 >=dev-python/sqlalchemy-1.0.10[${PYTHON_USEDEP}]
65                 <dev-python/sqlalchemy-1.1.0[${PYTHON_USEDEP}]
66         )
67         sqlite? (
68                 >=dev-python/sqlalchemy-1.0.10[sqlite,${PYTHON_USEDEP}]
69                 <dev-python/sqlalchemy-1.1.0[sqlite,${PYTHON_USEDEP}]
70         )
71         mysql? (
72                 >=dev-python/pymysql-0.6.2[${PYTHON_USEDEP}]
73                 !~dev-python/pymysql-0.7.7[${PYTHON_USEDEP}]
74                 >=dev-python/sqlalchemy-1.0.10[${PYTHON_USEDEP}]
75                 <dev-python/sqlalchemy-1.1.0[${PYTHON_USEDEP}]
76         )
77         postgres? (
78                 >=dev-python/psycopg-2.5.0
79                 >=dev-python/sqlalchemy-1.0.10[${PYTHON_USEDEP}]
80                 <dev-python/sqlalchemy-1.1.0[${PYTHON_USEDEP}]
81         )
82         >=dev-python/webob-1.2.3[${PYTHON_USEDEP}]
83         >=dev-python/keystoneauth-2.10.0[${PYTHON_USEDEP}]
84         >=dev-python/alembic-0.8.4[${PYTHON_USEDEP}]
85         >=dev-python/six-1.9.0[${PYTHON_USEDEP}]
86         >=dev-python/stevedore-1.16.0[${PYTHON_USEDEP}]
87         >=dev-python/oslo-cache-1.5.0[${PYTHON_USEDEP}]
88         >=dev-python/oslo-concurrency-3.8.0[${PYTHON_USEDEP}]
89         >=dev-python/oslo-config-3.14.0[${PYTHON_USEDEP}]
90         >=dev-python/oslo-context-2.9.0[${PYTHON_USEDEP}]
91         >=dev-python/oslo-db-4.10.0[${PYTHON_USEDEP}]
92         !~dev-python/oslo-db-4.13.1[${PYTHON_USEDEP}]
93         !~dev-python/oslo-db-4.13.2[${PYTHON_USEDEP}]
94         >=dev-python/oslo-i18n-2.1.0[${PYTHON_USEDEP}]
95         >=dev-python/oslo-log-1.14.0[${PYTHON_USEDEP}]
96         >=dev-python/oslo-messaging-5.2.0[${PYTHON_USEDEP}]
97         >=dev-python/oslo-middleware-3.0.0[${PYTHON_USEDEP}]
98         >=dev-python/oslo-policy-1.9.0[${PYTHON_USEDEP}]
99         >=dev-python/oslo-reports-0.6.0[${PYTHON_USEDEP}]
100         >=dev-python/oslo-rootwrap-5.0.0[${PYTHON_USEDEP}]
101         >=dev-python/oslo-serialization-1.10.0[${PYTHON_USEDEP}]
102         >=dev-python/oslo-service-1.10.0[${PYTHON_USEDEP}]
103         >=dev-python/oslo-utils-3.16.0[${PYTHON_USEDEP}]
104         >=dev-python/oslo-versionedobjects-1.13.0[${PYTHON_USEDEP}]
105         >=dev-python/osprofiler-1.4.0[${PYTHON_USEDEP}]
106         >=dev-python/ovs-2.6.0[${PYTHON_USEDEP}]
107         >=dev-python/python-novaclient-2.29.0[${PYTHON_USEDEP}]
108         !~dev-python/python-novaclient-2.33.0[${PYTHON_USEDEP}]
109         >=dev-python/python-designateclient-1.5.0[${PYTHON_USEDEP}]
110         virtual/python-singledispatch[${PYTHON_USEDEP}]
111         dev-python/pyudev[${PYTHON_USEDEP}]
112         sys-apps/iproute2
113         net-misc/iputils[arping]
114         net-misc/bridge-utils
115         net-firewall/ipset
116         net-firewall/iptables
117         net-firewall/ebtables
118         net-firewall/conntrack-tools
119         openvswitch? ( <=net-misc/openvswitch-2.6.9999 )
120         ipv6? (
121                 net-misc/radvd
122                 >=net-misc/dibbler-1.0.1
123         )
124         dhcp? ( net-dns/dnsmasq[dhcp-tools] )"
125
126 #PATCHES=(
127 #)
128
129 pkg_setup() {
130         linux-info_pkg_setup
131         CONFIG_CHECK_MODULES="VLAN_8021Q IP6_NF_FILTER IP6_NF_IPTABLES IP_NF_TARGET_REJECT \
132         IP_NF_MANGLE IP_NF_TARGET_MASQUERADE NF_NAT_IPV4 NF_CONNTRACK_IPV4 NF_DEFRAG_IPV4 \
133         NF_NAT_IPV4 NF_NAT NF_CONNTRACK IP_NF_FILTER IP_NF_IPTABLES NETFILTER_XTABLES"
134         if linux_config_exists; then
135                 for module in ${CONFIG_CHECK_MODULES}; do
136                         linux_chkconfig_present ${module} || ewarn "${module} needs to be enabled in kernel"
137                 done
138         fi
139         enewgroup neutron
140         enewuser neutron -1 -1 /var/lib/neutron neutron
141 }
142
143 pkg_config() {
144         fperms 0700 /var/log/neutron
145         fowners neutron:neutron /var/log neutron
146 }
147
148 src_prepare() {
149         sed -i '/^hacking/d' test-requirements.txt || die
150         # it's /bin/ip not /sbin/ip
151         sed -i 's/sbin\/ip\,/bin\/ip\,/g' etc/neutron/rootwrap.d/* || die
152         distutils-r1_python_prepare_all
153 }
154
155 python_install() {
156         distutils-r1_python_install
157         if use server; then
158                 newinitd "${FILESDIR}/neutron.initd" "neutron-server"
159                 newconfd "${FILESDIR}/neutron-server.confd" "neutron-server"
160                 dosym /etc/neutron/plugin.ini /etc/neutron/plugins/ml2/ml2_conf.ini
161         fi
162         if use dhcp; then
163                 newinitd "${FILESDIR}/neutron.initd" "neutron-dhcp-agent"
164                 newconfd "${FILESDIR}/neutron-dhcp-agent.confd" "neutron-dhcp-agent"
165         fi
166         if use l3; then
167                 newinitd "${FILESDIR}/neutron.initd" "neutron-l3-agent"
168                 newconfd "${FILESDIR}/neutron-l3-agent.confd" "neutron-l3-agent"
169         fi
170         if use metadata; then
171                 newinitd "${FILESDIR}/neutron.initd" "neutron-metadata-agent"
172                 newconfd "${FILESDIR}/neutron-metadata-agent.confd" "neutron-metadata-agent"
173         fi
174         if use openvswitch; then
175                 newinitd "${FILESDIR}/neutron.initd" "neutron-openvswitch-agent"
176                 newconfd "${FILESDIR}/neutron-openvswitch-agent.confd" "neutron-openvswitch-agent"
177                 newinitd "${FILESDIR}/neutron.initd" "neutron-ovs-cleanup"
178                 newconfd "${FILESDIR}/neutron-openvswitch-agent.confd" "neutron-ovs-cleanup"
179         fi
180         if use linuxbridge; then
181                 newinitd "${FILESDIR}/neutron.initd" "neutron-linuxbridge-agent"
182                 newconfd "${FILESDIR}/neutron-linuxbridge-agent.confd" "neutron-linuxbridge-agent"
183         fi
184         diropts -m 755 -o neutron -g neutron
185         dodir /var/log/neutron /var/lib/neutron
186         keepdir /etc/neutron
187         insinto /etc/neutron
188         insopts -m 0640 -o neutron -g neutron
189
190         doins etc/*
191         # stupid renames
192         insinto /etc/neutron
193         doins -r "etc/neutron/plugins"
194         insopts -m 0640 -o root -g root
195         doins "etc/rootwrap.conf"
196         doins -r "etc/neutron/rootwrap.d"
197
198         insopts -m 0644
199         insinto "/usr/lib64/python2.7/site-packages/neutron/db/migration/alembic_migrations/"
200         doins -r "neutron/db/migration/alembic_migrations/versions"
201
202         #add sudoers definitions for user neutron
203         insinto /etc/sudoers.d/
204         insopts -m 0440 -o root -g root
205         newins "${FILESDIR}/neutron.sudoersd" neutron
206
207         # add generated configs
208         cd "${D}/etc/neutron" || die
209         unpack "neutron-configs-${PV}.tar.gz"
210         cd "${D}/etc/neutron/plugins/ml2" || die
211         unpack "neutron-ml2-plugins-${PV}.tar.gz"
212
213         # correcting perms
214         fowners neutron:neutron -R "/etc/neutron"
215         fperms o-rwx -R "/etc/neutron/"
216
217         #remove superfluous stuff
218         rm -R "${D}/usr/etc/"
219 }
220
221 pkg_postinst() {
222         elog
223         elog "neutron-server's conf.d file may need updating to include additional ini files"
224         elog "We currently assume the ml2 plugin will be used but do not make assumptions"
225         elog "on if you will use openvswitch or linuxbridge (or something else)"
226         elog
227         elog "Other conf.d files may need updating too, but should be good for the default use case"
228         elog
229 }