blob: 5cab8e17166b6222a6a37869fd625140f0da3af0 [file] [log] [blame]
Sean M. Collins2a242512016-05-03 09:03:09 -04001#!/bin/bash
2#
3# lib/neutron
4# Install and start **Neutron** network services
5
6# Dependencies:
7#
8# ``functions`` file
9# ``DEST`` must be defined
10
11# ``stack.sh`` calls the entry points in this order:
12#
13# - is_XXXX_enabled
14# - install_XXXX
15# - configure_XXXX
16# - init_XXXX
17# - start_XXXX
18# - stop_XXXX
19# - cleanup_XXXX
20
21# Save trace setting
22XTRACE=$(set +o | grep xtrace)
23set +o xtrace
24
25# Defaults
26# --------
27
28# Set up default directories
29GITDIR["python-neutronclient"]=$DEST/python-neutronclient
30
31NEUTRON_AGENT=${NEUTRON_AGENT:-openvswitch}
32NEUTRON_DIR=$DEST/neutron
33NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron}
34
35NEUTRON_BIN_DIR=$(get_python_exec_prefix)
36NEUTRON_DHCP_BINARY="neutron-dhcp-agent"
37
38NEUTRON_CONF_DIR=/etc/neutron
39NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf
40NEUTRON_META_CONF=$NEUTRON_CONF_DIR/metadata_agent.ini
41
42NEUTRON_DHCP_CONF=$NEUTRON_CONF_DIR/dhcp_agent.ini
43NEUTRON_L3_CONF=$NEUTRON_CONF_DIR/l3_agent.ini
44NEUTRON_AGENT_CONF=$NEUTRON_CONF_DIR/
45
46NEUTRON_STATE_PATH=${NEUTRON_STATE_PATH:=$DATA_DIR/neutron}
47NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron}
48
49# By default, use the ML2 plugin
50NEUTRON_PLUGIN=${NEUTRON_PLUGIN:-ml2}
51NEUTRON_PLUGIN_CONF_FILENAME=${NEUTRON_PLUGIN_CONF_FILENAME:-ml2_conf.ini}
52NEUTRON_PLUGIN_CONF_PATH=$NEUTRON_CONF_DIR/plugins/$NEUTRON_PLUGIN
53NEUTRON_PLUGIN_CONF=$NEUTRON_PLUGIN_CONF_PATH/$NEUTRON_PLUGIN_CONF_FILENAME
54
55NEUTRON_AGENT_BINARY=${NEUTRON_AGENT_BINARY:-neutron-$NEUTRON_AGENT-agent}
56NEUTRON_L3_BINARY=${NEUTRON_L3_BINARY:-neutron-l3-agent}
57NEUTRON_META_BINARY=${NEUTRON_META_BINARY:-neutron-metadata-agent}
58
59# Public facing bits
60if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then
61 NEUTRON_SERVICE_PROTOCOL="https"
62fi
63NEUTRON_SERVICE_HOST=${NEUTRON_SERVICE_HOST:-$SERVICE_HOST}
64NEUTRON_SERVICE_PORT=${NEUTRON_SERVICE_PORT:-9696}
65NEUTRON_SERVICE_PORT_INT=${NEUTRON_SERVICE_PORT_INT:-19696}
66NEUTRON_SERVICE_PROTOCOL=${NEUTRON_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
67
68NEUTRON_AUTH_STRATEGY=${NEUTRON_AUTH_STRATEGY:-keystone}
69NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron)
70NEUTRON_ROOTWRAP_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf
71NEUTRON_ROOTWRAP_DAEMON_CMD="sudo $NEUTRON_ROOTWRAP-daemon $NEUTRON_ROOTWRAP_CONF_FILE"
72
73# Add all enabled config files to a single config arg
74NEUTRON_CONFIG_ARG=${NEUTRON_CONFIG_ARG:-""}
75
76# Functions
77# ---------
78
79# Test if any Neutron services are enabled
80# is_neutron_enabled
81function is_neutron_enabled {
82 [[ ,${ENABLED_SERVICES} =~ ,"neutron-" || ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0
83 return 1
84}
85
86# Test if any Neutron services are enabled
87# is_neutron_enabled
88function is_neutron_legacy_enabled {
89 [[ ,${ENABLED_SERVICES} =~ ,"q-" ]] && return 0
90 return 1
91}
92
93# cleanup_neutron() - Remove residual data files, anything left over from previous
94# runs that a clean run would need to clean up
95function cleanup_neutron_new {
96 source $TOP_DIR/lib/neutron_plugins/${NEUTRON_AGENT}_agent
97 if is_neutron_ovs_base_plugin; then
98 neutron_ovs_base_cleanup
99 fi
100
101 if [[ $NEUTRON_AGENT == "linuxbridge" ]]; then
102 neutron_lb_cleanup
103 fi
104 # delete all namespaces created by neutron
105 for ns in $(sudo ip netns list | grep -o -E '(qdhcp|qrouter|qlbaas|fip|snat)-[0-9a-f-]*'); do
106 sudo ip netns delete ${ns}
107 done
108}
109
110# configure_neutron() - Set config files, create data dirs, etc
111function configure_neutron_new {
112 sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR
113
114 (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh)
115
116 cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF
117
118 configure_neutron_rootwrap
119
120 mkdir -p $NEUTRON_PLUGIN_CONF_PATH
121
122 cp $NEUTRON_DIR/etc/neutron/plugins/$NEUTRON_PLUGIN/$NEUTRON_PLUGIN_CONF_FILENAME.sample $NEUTRON_PLUGIN_CONF
123
124 iniset $NEUTRON_CONF database connection `database_connection_url neutron`
125 iniset $NEUTRON_CONF DEFAULT state_path $NEUTRON_STATE_PATH
126 iniset $NEUTRON_CONF oslo_concurrency lock_path $NEUTRON_STATE_PATH/lock
127 iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG
128
Sean M. Collinsfbba3b92016-05-12 11:17:53 -0400129 iniset $NEUTRON_CONF DEFAULT debug True
130
Sean M. Collins5394cc12016-05-11 15:03:38 -0400131 iniset_rpc_backend neutron $NEUTRON_CONF
132
Sean M. Collins2a242512016-05-03 09:03:09 -0400133 # Neutron API server & Neutron plugin
134 if is_service_enabled neutron-api; then
135 local policy_file=$NEUTRON_CONF_DIR/policy.json
136 cp $NEUTRON_DIR/etc/policy.json $policy_file
137 # Allow neutron user to administer neutron to match neutron account
138 sed -i 's/"context_is_admin": "role:admin"/"context_is_admin": "role:admin or user_name:neutron"/g' $policy_file
139
140 cp $NEUTRON_DIR/etc/api-paste.ini $NEUTRON_CONF_DIR/api-paste.ini
141
142 iniset $NEUTRON_CONF DEFAULT core_plugin ml2
143
Sean M. Collins2a242512016-05-03 09:03:09 -0400144 iniset $NEUTRON_CONF DEFAULT policy_file $policy_file
145 iniset $NEUTRON_CONF DEFAULT allow_overlapping_ips True
146
147 iniset $NEUTRON_CONF DEFAULT auth_strategy $NEUTRON_AUTH_STRATEGY
148 configure_auth_token_middleware $NEUTRON_CONF neutron $NEUTRON_AUTH_CACHE_DIR keystone_authtoken
149
150 # Configuration for neutron notifations to nova.
151 iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES
152 iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_data_changes $Q_NOTIFY_NOVA_PORT_DATA_CHANGES
153
154 iniset $NEUTRON_CONF nova auth_type password
155 iniset $NEUTRON_CONF nova auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v3"
156 iniset $NEUTRON_CONF nova username nova
157 iniset $NEUTRON_CONF nova password $SERVICE_PASSWORD
158 iniset $NEUTRON_CONF nova user_domain_id default
159 iniset $NEUTRON_CONF nova project_name $SERVICE_TENANT_NAME
160 iniset $NEUTRON_CONF nova project_domain_id default
161 iniset $NEUTRON_CONF nova region_name $REGION_NAME
162
163 # Configure VXLAN
164 # TODO(sc68cal) not hardcode?
165 iniset $NEUTRON_PLUGIN_CONF ml2 tenant_network_types vxlan
166 iniset $NEUTRON_PLUGIN_CONF ml2 type_drivers vxlan
167 iniset $NEUTRON_PLUGIN_CONF ml2 mechanism_drivers openvswitch,linuxbridge
168 iniset $NEUTRON_PLUGIN_CONF ml2_type_vxlan vni_ranges 1001:2000
169 fi
170
171 # Neutron OVS or LB agent
172 if is_service_enabled neutron-agent; then
173 iniset $NEUTRON_PLUGIN_CONF agent tunnel_types vxlan
Sean M. Collinsfbba3b92016-05-12 11:17:53 -0400174 iniset $NEUTRON_PLUGIN_CONF DEFAULT debug True
Sean M. Collins2a242512016-05-03 09:03:09 -0400175
176 # Configure the neutron agent
177 if [[ $NEUTRON_AGENT == "linuxbridge" ]]; then
178 iniset $NEUTRON_PLUGIN_CONF securitygroup iptables
179 iniset $NEUTRON_PLUGIN_CONF vxlan local_ip $HOST_IP
180 else
181 iniset $NEUTRON_PLUGIN_CONF securitygroup iptables_hybrid
182 iniset $NEUTRON_PLUGIN_CONF ovs local_ip $HOST_IP
183 fi
184 fi
185
186 # DHCP Agent
187 if is_service_enabled neutron-dhcp; then
188 cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $NEUTRON_DHCP_CONF
189
Sean M. Collins2a242512016-05-03 09:03:09 -0400190 iniset $NEUTRON_DHCP_CONF DEFAULT debug True
191 iniset $NEUTRON_DHCP_CONF agent root_helper_daemon "$NEUTRON_ROOTWRAP_DAEMON_CMD"
192 iniset $NEUTRON_DHCP_CONF DEFAULT interface_driver $NEUTRON_AGENT
193 neutron_plugin_configure_dhcp_agent $NEUTRON_DHCP_CONF
194 fi
195
196 if is_service_enabled neutron-l3; then
197 cp $NEUTRON_DIR/etc/l3_agent.ini.sample $NEUTRON_L3_CONF
198 iniset $NEUTRON_L3_CONF DEFAULT interface_driver $NEUTRON_AGENT
199 iniset $NEUTRON_CONF DEFAULT service_plugins router
200 iniset $NEUTRON_L3_CONF agent root_helper_daemon "$NEUTRON_ROOTWRAP_DAEMON_CMD"
201 iniset $NEUTRON_L3_CONF DEFAULT debug True
Sean M. Collins2a242512016-05-03 09:03:09 -0400202 neutron_plugin_configure_l3_agent $NEUTRON_L3_CONF
203 fi
204
205 # Metadata
Sean M. Collins1cd28282016-05-11 15:07:19 -0400206 if is_service_enabled neutron-metadata-agent; then
Sean M. Collins2a242512016-05-03 09:03:09 -0400207 cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $NEUTRON_META_CONF
208
Sean M. Collinsfbba3b92016-05-12 11:17:53 -0400209 iniset $NEUTRON_META_CONF DEFAULT debug True
Sean M. Collins2a242512016-05-03 09:03:09 -0400210 iniset $NEUTRON_META_CONF DEFAULT nova_metadata_ip $SERVICE_HOST
211 iniset $NEUTRON_META_CONF agent root_helper_daemon "$NEUTRON_ROOTWRAP_DAEMON_CMD"
212
213 # TODO(dtroyer): remove the v2.0 hard code below
214 iniset $NEUTRON_META_CONF DEFAULT auth_url $KEYSTONE_SERVICE_URI/v2.0
215 configure_auth_token_middleware $NEUTRON_META_CONF neutron $NEUTRON_AUTH_CACHE_DIR DEFAULT
216 fi
217
218 # Format logging
219 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
220 setup_colorized_logging $NEUTRON_CONF DEFAULT project_id
221 else
222 # Show user_name and project_name by default
223 iniset $NEUTRON_CONF DEFAULT logging_context_format_string "%(asctime)s.%(msecs)03d %(levelname)s %(name)s [%(request_id)s %(user_name)s %(project_name)s] %(instance)s%(message)s"
224 fi
225
226 if is_service_enabled tls-proxy; then
227 # Set the service port for a proxy to take the original
228 iniset $NEUTRON_CONF DEFAULT bind_port "$NEUTRON_SERVICE_PORT_INT"
229 fi
230
231 if is_ssl_enabled_service "nova"; then
232 iniset $NEUTRON_CONF nova cafile $SSL_BUNDLE_FILE
233 fi
234
235 if is_ssl_enabled_service "neutron"; then
236 ensure_certificates NEUTRON
237
238 iniset $NEUTRON_CONF DEFAULT use_ssl True
239 iniset $NEUTRON_CONF DEFAULT ssl_cert_file "$NEUTRON_SSL_CERT"
240 iniset $NEUTRON_CONF DEFAULT ssl_key_file "$NEUTRON_SSL_KEY"
241 fi
242
Sean M. Collins8063fee2016-05-24 11:27:36 -0700243 # Metering
244 if is_service_enabled neutron-metering; then
Sean M. Collins60f394a2016-06-17 16:15:30 -0400245 source $TOP_DIR/lib/neutron_plugins/services/metering
Sean M. Collins8063fee2016-05-24 11:27:36 -0700246 neutron_agent_metering_configure_common
247 neutron_agent_metering_configure_agent
Sean M. Collinsa9286882016-06-20 13:23:11 -0400248 # TODO(sc68cal) hack because we don't pass around
249 # $Q_SERVICE_PLUGIN_CLASSES like -legacy does
250 local plugins=""
251 plugins=$(iniget $NEUTRON_CONF DEFAULT service_plugins)
252 plugins+=",metering"
253 iniset $NEUTRON_CONF DEFAULT service_plugins $plugins
Sean M. Collins8063fee2016-05-24 11:27:36 -0700254 fi
255
Sean M. Collins2a242512016-05-03 09:03:09 -0400256}
257
258# configure_neutron_rootwrap() - configure Neutron's rootwrap
259function configure_neutron_rootwrap {
260 # Set the paths of certain binaries
261 neutron_rootwrap=$(get_rootwrap_location neutron)
262
263 # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap
264 local rootwrap_sudoer_cmd="${neutron_rootwrap} $NEUTRON_CONF_DIR/rootwrap.conf"
265
266 # Deploy new rootwrap filters files (owned by root).
267 # Wipe any existing rootwrap.d files first
268 if [[ -d $NEUTRON_CONF_DIR/rootwrap.d ]]; then
269 sudo rm -rf $NEUTRON_CONF_DIR/rootwrap.d
270 fi
271
272 # Deploy filters to /etc/neutron/rootwrap.d
273 sudo install -d -o root -g root -m 755 $NEUTRON_CONF_DIR/rootwrap.d
274 sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/neutron/rootwrap.d/*.filters $NEUTRON_CONF_DIR/rootwrap.d
275
276 # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d``
277 sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/rootwrap.conf $NEUTRON_CONF_DIR
278 sudo sed -e "s:^filters_path=.*$:filters_path=$NEUTRON_CONF_DIR/rootwrap.d:" -i $NEUTRON_CONF_DIR/rootwrap.conf
279
280 # Set up the rootwrap sudoers for Neutron
281 tempfile=`mktemp`
282 echo "$STACK_USER ALL=(root) NOPASSWD: $rootwrap_sudoer_cmd *" >$tempfile
283 chmod 0440 $tempfile
284 sudo chown root:root $tempfile
285 sudo mv $tempfile /etc/sudoers.d/neutron-rootwrap
286}
287
288# Make Neutron-required changes to nova.conf
289function configure_neutron_nova_new {
290 iniset $NOVA_CONF DEFAULT use_neutron True
291 iniset $NOVA_CONF neutron auth_type "password"
292 iniset $NOVA_CONF neutron auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v3"
293 iniset $NOVA_CONF neutron username neutron
294 iniset $NOVA_CONF neutron password "$SERVICE_PASSWORD"
295 iniset $NOVA_CONF neutron user_domain_name "Default"
296 iniset $NOVA_CONF neutron project_name "$SERVICE_TENANT_NAME"
297 iniset $NOVA_CONF neutron project_domain_name "Default"
298 iniset $NOVA_CONF neutron auth_strategy $NEUTRON_AUTH_STRATEGY
299 iniset $NOVA_CONF neutron region_name "$REGION_NAME"
300 iniset $NOVA_CONF neutron url $NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT
301
302 iniset $NOVA_CONF DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
303
Sean M. Collins1cd28282016-05-11 15:07:19 -0400304 if is_service_enabled neutron-metadata-agent; then
Sean M. Collins2a242512016-05-03 09:03:09 -0400305 iniset $NOVA_CONF neutron service_metadata_proxy "True"
306 fi
307
308}
309
310# Tenant User Roles
311# ------------------------------------------------------------------
312# service neutron admin # if enabled
313
314# create_neutron_accounts() - Create required service accounts
315function create_neutron_accounts_new {
316 if [[ "$ENABLED_SERVICES" =~ "neutron-api" ]]; then
317
318 create_service_user "neutron"
319
320 neutron_service=$(get_or_create_service "neutron" \
321 "network" "Neutron Service")
322 get_or_create_endpoint $neutron_service \
323 "$REGION_NAME" \
324 "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/" \
325 "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/" \
326 "$NEUTRON_SERVICE_PROTOCOL://$NEUTRON_SERVICE_HOST:$NEUTRON_SERVICE_PORT/"
327 fi
328}
329
330# create_neutron_cache_dir() - Part of the init_neutron() process
331function create_neutron_cache_dir {
332 # Create cache dir
333 sudo install -d -o $STACK_USER $NEUTRON_AUTH_CACHE_DIR
334 rm -f $NEUTRON_AUTH_CACHE_DIR/*
335}
336
337# init_neutron() - Initialize databases, etc.
338function init_neutron_new {
339
340 recreate_database neutron
341
342 # Run Neutron db migrations
343 $NEUTRON_BIN_DIR/neutron-db-manage $NEUTRON_CONFIG_ARG upgrade heads
344
345 create_neutron_cache_dir
346}
347
348# install_neutron() - Collect source and prepare
349function install_neutron_new {
350 git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH
351 setup_develop $NEUTRON_DIR
352
353 # Install neutron-lib from git so we make sure we're testing
354 # the latest code.
355 if use_library_from_git "neutron-lib"; then
356 git_clone_by_name "neutron-lib"
357 setup_dev_lib "neutron-lib"
358 fi
359
360 # L3 service requires radvd
361 if is_service_enabled neutron-l3; then
362 install_package radvd
363 fi
364
365 if is_service_enabled neutron-agent neutron-dhcp neutron-l3; then
366 #TODO(sc68cal) - kind of ugly
367 source $TOP_DIR/lib/neutron_plugins/${NEUTRON_AGENT}_agent
368 neutron_plugin_install_agent_packages
369 fi
370
371}
372
373# install_neutronclient() - Collect source and prepare
374function install_neutronclient {
375 if use_library_from_git "python-neutronclient"; then
376 git_clone_by_name "python-neutronclient"
377 setup_dev_lib "python-neutronclient"
378 sudo install -D -m 0644 -o $STACK_USER {${GITDIR["python-neutronclient"]}/tools/,/etc/bash_completion.d/}neutron.bash_completion
379 fi
380}
381
382# start_neutron_api() - Start the API process ahead of other things
383function start_neutron_api {
384 local service_port=$NEUTRON_SERVICE_PORT
385 local service_protocol=$NEUTRON_SERVICE_PROTOCOL
386 if is_service_enabled tls-proxy; then
387 service_port=$NEUTRON_SERVICE_PORT_INT
388 service_protocol="http"
389 fi
390
391 # Start the Neutron service
392 # TODO(sc68cal) Stop hard coding this
393 run_process neutron-api "$NEUTRON_BIN_DIR/neutron-server --config-file $NEUTRON_CONF --config-file $NEUTRON_PLUGIN_CONF"
394
395 if is_ssl_enabled_service "neutron"; then
396 ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}"
397 local testcmd="wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$NEUTRON_SERVICE_HOST:$service_port"
398 test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT
399 else
400 if ! wait_for_service $SERVICE_TIMEOUT $service_protocol://$NEUTRON_SERVICE_HOST:$service_port; then
401 die $LINENO "neutron-api did not start"
402 fi
403 fi
404
405
406 # Start proxy if enabled
407 if is_service_enabled tls-proxy; then
408 start_tls_proxy '*' $NEUTRON_SERVICE_PORT $NEUTRON_SERVICE_HOST $NEUTRON_SERVICE_PORT_INT &
409 fi
410}
411
412# start_neutron() - Start running processes, including screen
413function start_neutron_new {
414 _set_config_files
415
416 # Start up the neutron agents if enabled
417 # TODO(sc68cal) Make this pluggable so different DevStack plugins for different Neutron plugins
418 # can resolve the $NEUTRON_AGENT_BINARY
419 if is_service_enabled neutron-agent; then
420 run_process neutron-agent "$NEUTRON_BIN_DIR/$NEUTRON_AGENT_BINARY $NEUTRON_CONFIG_ARG"
421 fi
422 if is_service_enabled neutron-dhcp; then
423 neutron_plugin_configure_dhcp_agent $NEUTRON_DHCP_CONF
424 run_process neutron-dhcp "$NEUTRON_BIN_DIR/$NEUTRON_DHCP_BINARY $NEUTRON_CONFIG_ARG"
425 fi
426 if is_service_enabled neutron-l3; then
427 run_process neutron-l3 "$NEUTRON_BIN_DIR/$NEUTRON_L3_BINARY $NEUTRON_CONFIG_ARG"
428 # XXX(sc68cal) - Here's where plugins can wire up their own networks instead
429 # of the code in lib/neutron_plugins/services/l3
430 if type -p neutron_plugin_create_initial_networks > /dev/null; then
431 neutron_plugin_create_initial_networks
432 else
433 # XXX(sc68cal) Load up the built in Neutron networking code and build a topology
434 source $TOP_DIR/lib/neutron_plugins/services/l3
435 # Create the networks using servic
436 create_neutron_initial_network
437 fi
438 fi
Sean M. Collins1cd28282016-05-11 15:07:19 -0400439 if is_service_enabled neutron-metadata-agent; then
440 run_process neutron-metadata-agent "$NEUTRON_BIN_DIR/$NEUTRON_META_BINARY $NEUTRON_CONFIG_ARG"
Sean M. Collins2a242512016-05-03 09:03:09 -0400441 fi
Sean M. Collins8063fee2016-05-24 11:27:36 -0700442
443 if is_service_enabled neutron-metering; then
444 run_process neutron-metering "$AGENT_METERING_BINARY --config-file $NEUTRON_CONF --config-file $METERING_AGENT_CONF_FILENAME"
445 fi
Sean M. Collins2a242512016-05-03 09:03:09 -0400446}
447
448# stop_neutron() - Stop running processes (non-screen)
449function stop_neutron_new {
450 for serv in neutron-api neutron-agent neutron-l3; do
451 stop_process $serv
452 done
453
454 if is_service_enabled neutron-dhcp; then
455 stop_process neutron-dhcp
456 pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }')
457 [ ! -z "$pid" ] && sudo kill -9 $pid
458 fi
459
Sean M. Collins1cd28282016-05-11 15:07:19 -0400460 if is_service_enabled neutron-metadata-agent; then
Sean M. Collins2a242512016-05-03 09:03:09 -0400461 sudo pkill -9 -f neutron-ns-metadata-proxy || :
Sean M. Collins1cd28282016-05-11 15:07:19 -0400462 stop_process neutron-metadata-agent
Sean M. Collins2a242512016-05-03 09:03:09 -0400463 fi
464}
465
466# Compile the lost of enabled config files
467function _set_config_files {
468
Sean M. Collinse7d2b562016-05-12 12:04:03 -0400469 NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_CONF"
Sean M. Collins2a242512016-05-03 09:03:09 -0400470
471 #TODO(sc68cal) OVS and LB agent uses settings in NEUTRON_PLUGIN_CONF (ml2_conf.ini) but others may not
472 if is_service_enabled neutron-agent; then
473 NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_PLUGIN_CONF"
474 fi
475
476 if is_service_enabled neutron-dhcp; then
477 NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_DHCP_CONF"
478 fi
479
480 if is_service_enabled neutron-l3; then
481 NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_L3_CONF"
482 fi
483
Sean M. Collins1cd28282016-05-11 15:07:19 -0400484 if is_service_enabled neutron-metadata-agent; then
Sean M. Collins2a242512016-05-03 09:03:09 -0400485 NEUTRON_CONFIG_ARG+=" --config-file $NEUTRON_META_CONF"
486 fi
487
488}
489
490# Dispatch functions
491# These are needed for compatibility between the old and new implementations
492# where there are function name overlaps. These will be removed when
493# neutron-legacy is removed.
494# TODO(sc68cal) Remove when neutron-legacy is no more.
495function cleanup_neutron {
496 if is_neutron_legacy_enabled; then
497 # Call back to old function
498 cleanup_mutnauq "$@"
499 else
500 cleanup_neutron_new "$@"
501 fi
502}
503
504function configure_neutron {
505 if is_neutron_legacy_enabled; then
506 # Call back to old function
507 configure_mutnauq "$@"
508 else
509 configure_neutron_new "$@"
510 fi
511}
512
513function configure_neutron_nova {
514 if is_neutron_legacy_enabled; then
515 # Call back to old function
516 create_nova_conf_neutron "$@"
517 else
518 configure_neutron_nova_new "$@"
519 fi
520}
521
522function create_neutron_accounts {
523 if is_neutron_legacy_enabled; then
524 # Call back to old function
525 create_mutnauq_accounts "$@"
526 else
527 create_neutron_accounts_new "$@"
528 fi
529}
530
531function init_neutron {
532 if is_neutron_legacy_enabled; then
533 # Call back to old function
534 init_mutnauq "$@"
535 else
536 init_neutron_new "$@"
537 fi
538}
539
540function install_neutron {
541 if is_neutron_legacy_enabled; then
542 # Call back to old function
543 install_mutnauq "$@"
544 else
545 install_neutron_new "$@"
546 fi
547}
548
549function start_neutron {
550 if is_neutron_legacy_enabled; then
551 # Call back to old function
552 start_mutnauq_l2_agent "$@"
553 start_mutnauq_other_agents "$@"
554 else
555 start_neutron_new "$@"
556 fi
557}
558
559function stop_neutron {
560 if is_neutron_legacy_enabled; then
561 # Call back to old function
562 stop_mutnauq "$@"
563 else
564 stop_neutron_new "$@"
565 fi
566}
567
568# Restore xtrace
569$XTRACE