summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-neutron_git.bb
blob: f9614873d480a41bef6fe5d87ecc1d44fe4e0337 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
DESCRIPTION = "Neutron (virtual network service)"
HOMEPAGE = "https://launchpad.net/neutron"
SECTION = "devel/python"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=1dece7821bf3fd70fe1309eaa37d52a2"

PR = "r0"
SRCNAME = "neutron"

SRC_URI = "git://github.com/openstack/${SRCNAME}.git;branch=master \
           file://ovs_neutron_plugin.ini \
           file://linuxbridge_conf.ini \
           file://neutron-server.init \
           file://neutron-agent.init \
           file://l3_agent.ini \
           file://dhcp_agent.ini \
           file://metadata_agent.ini \
           file://neutron-dhcp-agent-netns-cleanup.cron \
           file://0001-neutron.conf-jumpstart-nova-state-reporting-configur.patch \
           file://uuid_wscheck.patch \
           file://neutron-test-nec-plugin-extensions-location.patch \
	  "
SRCREV="3cd2550f1bb20dbbc00a01d8dfd8b53e00baa00d"
PV="2014.2.b3+git${SRCPV}"

S = "${WORKDIR}/git"

inherit setuptools update-rc.d identity hosts default_configs openstackchef

SERVICECREATE_PACKAGES = "${SRCNAME}-setup"
KEYSTONE_HOST="${CONTROLLER_IP}"

# USERCREATE_PARAM and SERVICECREATE_PARAM contain the list of parameters to be set.
# If the flag for a parameter in the list is not set here, the default value will be given to that parameter.
# Parameters not in the list will be set to empty.

USERCREATE_PARAM_${SRCNAME}-setup = "name pass tenant role email"
SERVICECREATE_PARAM_${SRCNAME}-setup = "name type description region publicurl adminurl internalurl"
python () {
    flags = {'type':'network',\
             'description':'OpenStack Networking service',\
             'publicurl':"'http://${KEYSTONE_HOST}:9696/'",\
             'adminurl':"'http://${KEYSTONE_HOST}:9696/'",\
             'internalurl':"'http://${KEYSTONE_HOST}:9696/'"}

    d.setVarFlags("SERVICECREATE_PARAM_%s-setup" % d.getVar('SRCNAME',True), flags)
}

do_install_append() {
    TEMPLATE_CONF_DIR=${S}${sysconfdir}/
    NEUTRON_CONF_DIR=${D}${sysconfdir}/neutron

    install -d ${NEUTRON_CONF_DIR}
    install -d ${NEUTRON_CONF_DIR}/plugins/openvswitch
    install -d ${NEUTRON_CONF_DIR}/plugins/linuxbridge

    install -m 600 ${TEMPLATE_CONF_DIR}/neutron.conf ${NEUTRON_CONF_DIR}/
    install -m 600 ${WORKDIR}/ovs_neutron_plugin.ini ${NEUTRON_CONF_DIR}/plugins/openvswitch/
    install -m 600 ${WORKDIR}/linuxbridge_conf.ini ${NEUTRON_CONF_DIR}/plugins/linuxbridge/
    install -m 600 ${S}/etc/api-paste.ini ${NEUTRON_CONF_DIR}/
    install -m 600 ${S}/etc/policy.json ${NEUTRON_CONF_DIR}/

    #sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \
    #    -i ${NEUTRON_CONF_DIR}/neutron.conf
    #sed -e "s:%SERVICE_USER%:${SRCNAME}:g" -i ${NEUTRON_CONF_DIR}/neutron.conf
    #sed -e "s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g" \
    #    -i ${NEUTRON_CONF_DIR}/neutron.conf
    sed -e "s:^# core_plugin.*:core_plugin = neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2:g" \
        -i ${NEUTRON_CONF_DIR}/neutron.conf

    # disable reporting of state changes to nova
    sed -e "s:^# notify_nova_on_port_status_changes.*:notify_nova_on_port_status_changes = False:g" \
        -i ${NEUTRON_CONF_DIR}/neutron.conf
    sed -e "s:^# notify_nova_on_port_data_changes.*:notify_nova_on_port_data_changes = False:g" \
        -i ${NEUTRON_CONF_DIR}/neutron.conf

    sed -e "s:^# rabbit_host =.*:rabbit_host = %CONTROLLER_IP%:" -i ${NEUTRON_CONF_DIR}/neutron.conf

    PLUGIN=openvswitch
    ARGS="--config-file=${sysconfdir}/${SRCNAME}/neutron.conf --config-file=${sysconfdir}/${SRCNAME}/plugins/openvswitch/ovs_neutron_plugin.ini"
    if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
        install -d ${D}${sysconfdir}/init.d
        sed "s:@plugin@:/etc/neutron/plugins/$PLUGIN/ovs_neutron_plugin.ini:" \
             < ${WORKDIR}/neutron-server.init >${WORKDIR}/neutron-server.init.sh
        install -m 0755 ${WORKDIR}/neutron-server.init.sh ${D}${sysconfdir}/init.d/neutron-server
        sed "s:@suffix@:$PLUGIN:;s:@args@:$ARGS:" < ${WORKDIR}/neutron-agent.init >${WORKDIR}/neutron-$PLUGIN.init.sh
        install -m 0755 ${WORKDIR}/neutron-$PLUGIN.init.sh ${D}${sysconfdir}/init.d/neutron-$PLUGIN-agent
    fi

    AGENT=dhcp
    ARGS="--config-file=${sysconfdir}/${SRCNAME}/neutron.conf --config-file=${sysconfdir}/${SRCNAME}/dhcp_agent.ini"
    if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
        sed "s:@suffix@:$AGENT:;s:@args@:$ARGS:" < ${WORKDIR}/neutron-agent.init >${WORKDIR}/neutron-$AGENT.init.sh
        install -m 0755 ${WORKDIR}/neutron-$AGENT.init.sh ${D}${sysconfdir}/init.d/neutron-$AGENT-agent
        install -m 600 ${WORKDIR}/${AGENT}_agent.ini ${NEUTRON_CONF_DIR}/
        sed "s:@bindir@:${bindir}:g;s:@confdir@:${sysconfdir}:g" < ${WORKDIR}/neutron-dhcp-agent-netns-cleanup.cron >${WORKDIR}/neutron-dhcp-agent-netns-cleanup
        install -d ${D}${sysconfdir}/cron.d
        install -m 644 ${WORKDIR}/neutron-dhcp-agent-netns-cleanup ${D}${sysconfdir}/cron.d/
    fi

    AGENT=l3
    ARGS="--config-file=${sysconfdir}/${SRCNAME}/neutron.conf --config-file=${sysconfdir}/${SRCNAME}/l3_agent.ini"
    if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
        sed "s:@suffix@:$AGENT:;s:@args@:$ARGS:" < ${WORKDIR}/neutron-agent.init >${WORKDIR}/neutron-$AGENT.init.sh
        install -m 0755 ${WORKDIR}/neutron-$AGENT.init.sh ${D}${sysconfdir}/init.d/neutron-$AGENT-agent
        install -m 600 ${WORKDIR}/${AGENT}_agent.ini ${NEUTRON_CONF_DIR}/
    fi

    AGENT=metadata
    ARGS="--config-file=${sysconfdir}/${SRCNAME}/neutron.conf --config-file=${sysconfdir}/${SRCNAME}/metadata_agent.ini"
    if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
        sed "s:@suffix@:$AGENT:;s:@args@:$ARGS:" < ${WORKDIR}/neutron-agent.init >${WORKDIR}/neutron-$AGENT.init.sh
        install -m 0755 ${WORKDIR}/neutron-$AGENT.init.sh ${D}${sysconfdir}/init.d/neutron-$AGENT-agent
        install -m 600 ${WORKDIR}/${AGENT}_agent.ini ${NEUTRON_CONF_DIR}/
    fi
    if [ -z "${OPENSTACKCHEF_ENABLED}" ]; then
        for file in plugins/openvswitch/ovs_neutron_plugin.ini \
            plugins/linuxbridge/linuxbridge_conf.ini neutron.conf metadata_agent.ini; do
        sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \
            -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%SERVICE_USER%:${SRCNAME}:g" \
            -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%SERVICE_PASSWORD%:${SERVICE_PASSWORD}:g" \
            -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%METADATA_SHARED_SECRET%:${METADATA_SHARED_SECRET}:g" \
            -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%DB_USER%:${DB_USER}:g" -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${NEUTRON_CONF_DIR}/$file
        sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${NEUTRON_CONF_DIR}/$file
        done
    fi
    sed -e "s:^auth_host.*:#auth_host:g" -i ${NEUTRON_CONF_DIR}/neutron.conf
    sed -e "s:^auth_port.*:#auth_port:g" -i ${NEUTRON_CONF_DIR}/neutron.conf
    sed -e "s:^auth_protocol.*:#auth_protocol:g" -i ${NEUTRON_CONF_DIR}/neutron.conf
    sed -i '/\[keystone_authtoken\]/aidentity_uri=http://127.0.0.1:8081/keystone/admin/' ${NEUTRON_CONF_DIR}/neutron.conf

    cp run_tests.sh ${NEUTRON_CONF_DIR}

    sed 's:%PYTHON_SITEPACKAGES_DIR%:${PYTHON_SITEPACKAGES_DIR}:g' -i ${D}${PYTHON_SITEPACKAGES_DIR}/${SRCNAME}/tests/unit/nec/test_nec_plugin.py
}

pkg_postinst_${SRCNAME}-setup () {
    if [ "x$D" != "x" ]; then
        exit 1
    fi

    # This is to make sure postgres is configured and running
    if ! pidof postmaster > /dev/null; then
        /etc/init.d/postgresql-init
        /etc/init.d/postgresql start
        sleep 2
    fi

    sudo -u postgres createdb ovs_neutron
    sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
                           --config-file /etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini upgrade head
}

CHEF_SERVICES_CONF_FILES := " \
    ${sysconfdir}/${SRCNAME}/neutron.conf \
    ${sysconfdir}/${SRCNAME}/metadata_agent.ini \
    ${sysconfdir}/${SRCNAME}/plugins/openvswitch/ovs_neutron_plugin.ini \
    ${sysconfdir}/${SRCNAME}/plugins/linuxbridge/linuxbridge_conf.ini \
    "
deploychef_services_special_func(){
    #This function is a callback function for the deploychef .bbclass
    #We define this special callback funtion because we are doing 
    #more than a placeholder substitution. The variable CHEF_SERVICES_FILE_NAME
    #is defined in deploychef_framework.bbclass
    if [ -n "${CHEF_SERVICES_FILE_NAME}" ]; then
        sed "s:^# rabbit_host =.*:rabbit_host = %CONTROLLER_IP%:" -i \
        ${CHEF_SERVICES_FILE_NAME}
    fi
}

CHEF_SERVICES_SPECIAL_FUNC := "deploychef_services_special_func"

pkg_postinst_${SRCNAME}-plugin-openvswitch-setup () {
    if [ "x$D" != "x" ]; then
        exit 1
    fi
   
    /etc/init.d/openvswitch-switch start
    ovs-vsctl --no-wait -- --may-exist add-br br-int
}

ALLOW_EMPTY_${SRCNAME}-setup = "1"
ALLOW_EMPTY_${SRCNAME}-plugin-openvswitch-setup = "1"

PACKAGES += " \
     ${SRCNAME}-tests \
     ${SRCNAME} \
     ${SRCNAME}-doc \
     ${SRCNAME}-server \
     ${SRCNAME}-plugin-openvswitch \
     ${SRCNAME}-plugin-linuxbridge \
     ${SRCNAME}-dhcp-agent \
     ${SRCNAME}-l3-agent \
     ${SRCNAME}-metadata-agent \
     ${SRCNAME}-extra-agents \
     ${SRCNAME}-setup \
     ${SRCNAME}-plugin-openvswitch-setup \
     "

FILES_${PN} = "${libdir}/*"

FILES_${SRCNAME}-tests = "${sysconfdir}/${SRCNAME}/run_tests.sh"

FILES_${SRCNAME} = " \
    ${bindir}/neutron-db-manage \
    ${bindir}/neutron-rootwrap \
    ${bindir}/neutron-debug \
    ${bindir}/neutron-netns-cleanup \
    ${bindir}/neutron-ovs-cleanup \
    ${sysconfdir}/${SRCNAME}/policy.json \
    ${sysconfdir}/${SRCNAME}/neutron.conf \
    ${sysconfdir}/${SRCNAME}/api-paste.ini \
    ${localstatedir}/* \    
    "

FILES_${SRCNAME}-server = "${bindir}/neutron-server \
    ${sysconfdir}/init.d/neutron-server \
    "

FILES_${SRCNAME}-plugin-openvswitch = " \
    ${bindir}/neutron-openvswitch-agent \
    ${sysconfdir}/${SRCNAME}/plugins/openvswitch/ovs_neutron_plugin.ini \
    ${sysconfdir}/init.d/neutron-openvswitch-agent \
    "

FILES_${SRCNAME}-plugin-linuxbridge = " \
    ${bindir}/neutron-linuxbridge-agent \
    ${sysconfdir}/${SRCNAME}/plugins/linuxbridge/linuxbridge_conf.ini \
    ${sysconfdir}/init.d/neutron-linuxbridge-agent \
    "

FILES_${SRCNAME}-dhcp-agent = "${bindir}/neutron-dhcp-agent \
    ${bindir}/neutron-dhcp-agent-dnsmasq-lease-update \
    ${sysconfdir}/${SRCNAME}/dhcp_agent.ini \
    ${sysconfdir}/init.d/neutron-dhcp-agent \
    ${sysconfdir}/cron.d/neutron-dhcp-agent-netns-cleanup \
    "

FILES_${SRCNAME}-l3-agent = "${bindir}/neutron-l3-agent \
    ${sysconfdir}/${SRCNAME}/l3_agent.ini \
    ${sysconfdir}/init.d/neutron-l3-agent \
    "

FILES_${SRCNAME}-metadata-agent = "${bindir}/neutron-metadata-agent \
    ${bindir}/neutron-ns-metadata-proxy \
    ${sysconfdir}/${SRCNAME}/metadata_agent.ini \
    ${sysconfdir}/init.d/neutron-metadata-agent \
    "

FILES_${SRCNAME}-extra-agents = "${bindir}/*"

FILES_${SRCNAME}-doc = "${datadir}/*"

DEPENDS += " \
        python-pip \
        python-pbr \
        "

RDEPENDS_${PN} += "python-paste \
	python-pastedeploy \
	python-routes \
	python-amqplib \
	python-anyjson \
	python-alembic \
	python-eventlet \
	python-greenlet \
	python-httplib2 \
	python-iso8601 \
	python-kombu \
	python-netaddr \
	python-neutronclient \
	python-sqlalchemy \
	python-webob \
	python-keystoneclient \
	python-oslo.config \
	python-pyudev \
	python-novaclient \
	python-mako \
	python-markupsafe \
	python-pyparsing \
	python-pbr \
	"

RDEPENDS_${SRCNAME} = "${PN} \
        postgresql postgresql-client python-psycopg2"

RDEPENDS_${SRCNAME}-server = "${SRCNAME}"
RDEPENDS_${SRCNAME}-plugin-openvswitch = "${SRCNAME} ${SRCNAME}-plugin-openvswitch-setup openvswitch-switch iproute2"
RDEPENDS_${SRCNAME}-plugin-openvswitch-setup = "openvswitch-switch "
RDEPENDS_${SRCNAME}-plugin-linuxbridge = "${SRCNAME} bridge-utils"
RDEPENDS_${SRCNAME}-dhcp-agent = "${SRCNAME} dnsmasq dhcp-server dhcp-server-config"
RDEPENDS_${SRCNAME}-l3-agent = "${SRCNAME} ${SRCNAME}-metadata-agent iputils"
RDEPENDS_${SRCNAME}-setup = "postgresql sudo"

RRECOMMENDS_${SRCNAME}-server = "${SRCNAME}-plugin-openvswitch"

INITSCRIPT_PACKAGES = "${SRCNAME}-server ${SRCNAME}-plugin-openvswitch ${SRCNAME}-plugin-linuxbridge ${SRCNAME}-dhcp-agent ${SRCNAME}-l3-agent ${SRCNAME}-metadata-agent"
INITSCRIPT_NAME_${SRCNAME}-server = "neutron-server"
INITSCRIPT_PARAMS_${SRCNAME}-server = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
INITSCRIPT_NAME_${SRCNAME}-plugin-openvswitch = "neutron-openvswitch-agent"
INITSCRIPT_PARAMS_${SRCNAME}-plugin-openvswitch = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
INITSCRIPT_NAME_${SRCNAME}-plugin-linuxbridge = "neutron-linuxbridge-agent"
INITSCRIPT_PARAMS_${SRCNAME}-plugin-linuxbridge = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
INITSCRIPT_NAME_${SRCNAME}-dhcp-agent = "neutron-dhcp-agent"
INITSCRIPT_PARAMS_${SRCNAME}-dhcp-agent = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
INITSCRIPT_NAME_${SRCNAME}-l3-agent = "neutron-l3-agent"
INITSCRIPT_PARAMS_${SRCNAME}-l3-agent = "${OS_DEFAULT_INITSCRIPT_PARAMS}"
INITSCRIPT_NAME_${SRCNAME}-metadata-agent = "neutron-metadata-agent"
INITSCRIPT_PARAMS_${SRCNAME}-metadata-agent = "${OS_DEFAULT_INITSCRIPT_PARAMS}"