blob: 9834b59f669581a3928bf4b3547a5942ff7d830f [file] [log] [blame]
Mark McClainb05c8762013-07-06 23:29:39 -04001# lib/neutron
2# functions - funstions specific to neutron
3
4# Dependencies:
5# ``functions`` file
6# ``DEST`` must be defined
7
8# ``stack.sh`` calls the entry points in this order:
9#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010010# - install_neutron
11# - install_neutronclient
12# - install_neutron_agent_packages
13# - install_neutron_third_party
14# - configure_neutron
15# - init_neutron
16# - configure_neutron_third_party
17# - init_neutron_third_party
18# - start_neutron_third_party
19# - create_nova_conf_neutron
20# - start_neutron_service_and_check
21# - create_neutron_initial_network
22# - setup_neutron_debug
23# - start_neutron_agents
Mark McClainb05c8762013-07-06 23:29:39 -040024#
25# ``unstack.sh`` calls the entry points in this order:
26#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010027# - stop_neutron
Mark McClainb05c8762013-07-06 23:29:39 -040028
29# Functions in lib/neutron are classified into the following categories:
30#
31# - entry points (called from stack.sh or unstack.sh)
32# - internal functions
33# - neutron exercises
34# - 3rd party programs
35
36
37# Neutron Networking
38# ------------------
39
40# Make sure that neutron is enabled in ``ENABLED_SERVICES``. If you want
41# to run Neutron on this host, make sure that q-svc is also in
42# ``ENABLED_SERVICES``.
43#
44# If you're planning to use the Neutron openvswitch plugin, set
45# ``Q_PLUGIN`` to "openvswitch" and make sure the q-agt service is enabled
46# in ``ENABLED_SERVICES``. If you're planning to use the Neutron
47# linuxbridge plugin, set ``Q_PLUGIN`` to "linuxbridge" and make sure the
48# q-agt service is enabled in ``ENABLED_SERVICES``.
49#
50# See "Neutron Network Configuration" below for additional variables
51# that must be set in localrc for connectivity across hosts with
52# Neutron.
53#
54# With Neutron networking the NETWORK_MANAGER variable is ignored.
55#
56# To enable specific configuration options for either the Open vSwitch or
57# LinuxBridge plugin, please see the top level README file under the
58# Neutron section.
59
60# Save trace setting
61XTRACE=$(set +o | grep xtrace)
62set +o xtrace
63
64
65# Neutron Network Configuration
66# -----------------------------
67
68# Gateway and subnet defaults, in case they are not customized in localrc
69NETWORK_GATEWAY=${NETWORK_GATEWAY:-10.0.0.1}
70PUBLIC_NETWORK_GATEWAY=${PUBLIC_NETWORK_GATEWAY:-172.24.4.225}
71PRIVATE_SUBNET_NAME=${PRIVATE_SUBNET_NAME:-"private-subnet"}
72PUBLIC_SUBNET_NAME=${PUBLIC_SUBNET_NAME:-"public-subnet"}
73
74# Set up default directories
75NEUTRON_DIR=$DEST/neutron
76NEUTRONCLIENT_DIR=$DEST/python-neutronclient
77NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron}
78
79# Support entry points installation of console scripts
80if [[ -d $NEUTRON_DIR/bin/neutron-server ]]; then
81 NEUTRON_BIN_DIR=$NEUTRON_DIR/bin
Sean Dague3bdb9222013-10-22 08:36:16 -040082else
83 NEUTRON_BIN_DIR=$(get_python_exec_prefix)
Mark McClainb05c8762013-07-06 23:29:39 -040084fi
85
86NEUTRON_CONF_DIR=/etc/neutron
87NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf
88export NEUTRON_TEST_CONFIG_FILE=${NEUTRON_TEST_CONFIG_FILE:-"$NEUTRON_CONF_DIR/debug.ini"}
89
90# Default Neutron Plugin
Kyle Mestery6d235002013-09-18 20:27:08 +000091Q_PLUGIN=${Q_PLUGIN:-ml2}
Mark McClainb05c8762013-07-06 23:29:39 -040092# Default Neutron Port
93Q_PORT=${Q_PORT:-9696}
94# Default Neutron Host
95Q_HOST=${Q_HOST:-$SERVICE_HOST}
96# Default admin username
97Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-neutron}
98# Default auth strategy
99Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
100# Use namespace or not
101Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
102# RHEL's support for namespaces requires using veths with ovs
103Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False}
104Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
105# Meta data IP
106Q_META_DATA_IP=${Q_META_DATA_IP:-$SERVICE_HOST}
107# Allow Overlapping IP among subnets
108Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True}
109# Use neutron-debug command
110Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
111# The name of the default q-l3 router
112Q_ROUTER_NAME=${Q_ROUTER_NAME:-router1}
Aaron Rosen4540d002013-10-24 13:59:33 -0700113# nova vif driver that all plugins should use
114NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
115
116
Mark McClainb05c8762013-07-06 23:29:39 -0400117# List of config file names in addition to the main plugin config file
118# See _configure_neutron_common() for details about setting it up
119declare -a Q_PLUGIN_EXTRA_CONF_FILES
120
121if is_service_enabled neutron; then
122 Q_RR_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf
123 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
124 Q_RR_COMMAND="sudo"
125 else
126 NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron)
127 Q_RR_COMMAND="sudo $NEUTRON_ROOTWRAP $Q_RR_CONF_FILE"
128 fi
129
130 # Provider Network Configurations
131 # --------------------------------
132
133 # The following variables control the Neutron openvswitch and
134 # linuxbridge plugins' allocation of tenant networks and
135 # availability of provider networks. If these are not configured
136 # in ``localrc``, tenant networks will be local to the host (with no
137 # remote connectivity), and no physical resources will be
138 # available for the allocation of provider networks.
139
140 # To use GRE tunnels for tenant networks, set to True in
141 # ``localrc``. GRE tunnels are only supported by the openvswitch
142 # plugin, and currently only on Ubuntu.
143 ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-False}
144
145 # If using GRE tunnels for tenant networks, specify the range of
146 # tunnel IDs from which tenant networks are allocated. Can be
147 # overriden in ``localrc`` in necesssary.
148 TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGE:-1:1000}
149
150 # To use VLANs for tenant networks, set to True in localrc. VLANs
151 # are supported by the openvswitch and linuxbridge plugins, each
152 # requiring additional configuration described below.
153 ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False}
154
155 # If using VLANs for tenant networks, set in ``localrc`` to specify
156 # the range of VLAN VIDs from which tenant networks are
157 # allocated. An external network switch must be configured to
158 # trunk these VLANs between hosts for multi-host connectivity.
159 #
160 # Example: ``TENANT_VLAN_RANGE=1000:1999``
161 TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-}
162
163 # If using VLANs for tenant networks, or if using flat or VLAN
164 # provider networks, set in ``localrc`` to the name of the physical
165 # network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the
166 # openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge
167 # agent, as described below.
168 #
169 # Example: ``PHYSICAL_NETWORK=default``
170 PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-}
171
172 # With the openvswitch plugin, if using VLANs for tenant networks,
173 # or if using flat or VLAN provider networks, set in ``localrc`` to
174 # the name of the OVS bridge to use for the physical network. The
175 # bridge will be created if it does not already exist, but a
176 # physical interface must be manually added to the bridge as a
177 # port for external connectivity.
178 #
179 # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1``
180 OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-}
181
182 # With the linuxbridge plugin, if using VLANs for tenant networks,
183 # or if using flat or VLAN provider networks, set in ``localrc`` to
184 # the name of the network interface to use for the physical
185 # network.
186 #
187 # Example: ``LB_PHYSICAL_INTERFACE=eth1``
188 LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-}
189
190 # With the openvswitch plugin, set to True in ``localrc`` to enable
191 # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False.
192 #
193 # Example: ``OVS_ENABLE_TUNNELING=True``
194 OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
195fi
196
197# Neutron plugin specific functions
198# ---------------------------------
199
200# Please refer to ``lib/neutron_plugins/README.md`` for details.
201source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN
202
203# Agent loadbalancer service plugin functions
204# -------------------------------------------
205
206# Hardcoding for 1 service plugin for now
207source $TOP_DIR/lib/neutron_plugins/services/loadbalancer
208
Nachi Ueno69b3ff62013-06-07 10:28:33 -0700209# VPN service plugin functions
210# -------------------------------------------
211# Hardcoding for 1 service plugin for now
212source $TOP_DIR/lib/neutron_plugins/services/vpn
213
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700214# Firewall Service Plugin functions
Adam Spierscb961592013-10-05 12:11:07 +0100215# ---------------------------------
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700216source $TOP_DIR/lib/neutron_plugins/services/firewall
217
Mark McClainb05c8762013-07-06 23:29:39 -0400218# Use security group or not
219if has_neutron_plugin_security_group; then
220 Q_USE_SECGROUP=${Q_USE_SECGROUP:-True}
221else
222 Q_USE_SECGROUP=False
223fi
224
225# Functions
226# ---------
227
228# configure_neutron()
229# Set common config for all neutron server and agents.
230function configure_neutron() {
231 _configure_neutron_common
232 iniset_rpc_backend neutron $NEUTRON_CONF DEFAULT
233
234 # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES
235 if is_service_enabled q-lbaas; then
236 _configure_neutron_lbaas
237 fi
Nachi Ueno69b3ff62013-06-07 10:28:33 -0700238 if is_service_enabled q-vpn; then
239 _configure_neutron_vpn
240 fi
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700241 if is_service_enabled q-fwaas; then
242 _configure_neutron_fwaas
243 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400244 if is_service_enabled q-svc; then
245 _configure_neutron_service
246 fi
247 if is_service_enabled q-agt; then
248 _configure_neutron_plugin_agent
249 fi
250 if is_service_enabled q-dhcp; then
251 _configure_neutron_dhcp_agent
252 fi
253 if is_service_enabled q-l3; then
254 _configure_neutron_l3_agent
255 fi
256 if is_service_enabled q-meta; then
257 _configure_neutron_metadata_agent
258 fi
259
260 _configure_neutron_debug_command
261}
262
263function create_nova_conf_neutron() {
Yong Sheng Gong032e4542013-08-25 10:21:10 +0800264 iniset $NOVA_CONF DEFAULT network_api_class "nova.network.neutronv2.api.API"
265 iniset $NOVA_CONF DEFAULT neutron_admin_username "$Q_ADMIN_USERNAME"
266 iniset $NOVA_CONF DEFAULT neutron_admin_password "$SERVICE_PASSWORD"
267 iniset $NOVA_CONF DEFAULT neutron_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
268 iniset $NOVA_CONF DEFAULT neutron_auth_strategy "$Q_AUTH_STRATEGY"
269 iniset $NOVA_CONF DEFAULT neutron_admin_tenant_name "$SERVICE_TENANT_NAME"
270 iniset $NOVA_CONF DEFAULT neutron_region_name "RegionOne"
271 iniset $NOVA_CONF DEFAULT neutron_url "http://$Q_HOST:$Q_PORT"
Mark McClainb05c8762013-07-06 23:29:39 -0400272
273 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
274 LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
Yong Sheng Gong032e4542013-08-25 10:21:10 +0800275 iniset $NOVA_CONF DEFAULT security_group_api neutron
Mark McClainb05c8762013-07-06 23:29:39 -0400276 fi
277
278 # set NOVA_VIF_DRIVER and optionally set options in nova_conf
279 neutron_plugin_create_nova_conf
280
281 iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER"
282 iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER"
283 if is_service_enabled q-meta; then
Yong Sheng Gong032e4542013-08-25 10:21:10 +0800284 iniset $NOVA_CONF DEFAULT service_neutron_metadata_proxy "True"
Mark McClainb05c8762013-07-06 23:29:39 -0400285 fi
286}
287
288# create_neutron_accounts() - Set up common required neutron accounts
289
290# Tenant User Roles
291# ------------------------------------------------------------------
292# service neutron admin # if enabled
293
294# Migrated from keystone_data.sh
295function create_neutron_accounts() {
296
297 SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
298 ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
299
300 if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
301 NEUTRON_USER=$(keystone user-create \
302 --name=neutron \
303 --pass="$SERVICE_PASSWORD" \
304 --tenant_id $SERVICE_TENANT \
305 --email=neutron@example.com \
306 | grep " id " | get_field 2)
307 keystone user-role-add \
Jorge Valderrama Romerof39ee962013-09-02 17:18:40 +0200308 --tenant-id $SERVICE_TENANT \
309 --user-id $NEUTRON_USER \
310 --role-id $ADMIN_ROLE
Mark McClainb05c8762013-07-06 23:29:39 -0400311 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
312 NEUTRON_SERVICE=$(keystone service-create \
313 --name=neutron \
314 --type=network \
315 --description="Neutron Service" \
316 | grep " id " | get_field 2)
317 keystone endpoint-create \
318 --region RegionOne \
319 --service_id $NEUTRON_SERVICE \
320 --publicurl "http://$SERVICE_HOST:9696/" \
321 --adminurl "http://$SERVICE_HOST:9696/" \
322 --internalurl "http://$SERVICE_HOST:9696/"
323 fi
324 fi
325}
326
327function create_neutron_initial_network() {
328 TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
329
330 # Create a small network
331 # Since neutron command is executed in admin context at this point,
332 # ``--tenant_id`` needs to be specified.
333 if is_baremetal; then
sbauzae2c4ee22013-08-29 17:29:46 +0200334 if [[ "$PUBLIC_INTERFACE" == '' || "$OVS_PHYSICAL_BRIDGE" == '' ]]; then
335 die $LINENO "Neutron settings for baremetal not set.. exiting"
336 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400337 sudo ovs-vsctl add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE
338 for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do
339 sudo ip addr del $IP dev $PUBLIC_INTERFACE
340 sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
341 done
342 NET_ID=$(neutron net-create $PHYSICAL_NETWORK --tenant_id $TENANT_ID --provider:network_type flat --provider:physical_network "$PHYSICAL_NETWORK" | grep ' id ' | get_field 2)
343 SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
344 sudo ifconfig $OVS_PHYSICAL_BRIDGE up
sbauzae2c4ee22013-08-29 17:29:46 +0200345 sudo route add default gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE
Mark McClainb05c8762013-07-06 23:29:39 -0400346 else
347 NET_ID=$(neutron net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
348 SUBNET_ID=$(neutron subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY --name $PRIVATE_SUBNET_NAME $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
349 fi
350
351 if [[ "$Q_L3_ENABLED" == "True" ]]; then
352 # Create a router, and add the private subnet as one of its interfaces
353 if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
354 # create a tenant-owned router.
355 ROUTER_ID=$(neutron router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2)
356 else
357 # Plugin only supports creating a single router, which should be admin owned.
358 ROUTER_ID=$(neutron router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
359 fi
360 neutron router-interface-add $ROUTER_ID $SUBNET_ID
361 # Create an external network, and a subnet. Configure the external network as router gw
362 EXT_NET_ID=$(neutron net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
363 EXT_GW_IP=$(neutron subnet-create --ip_version 4 ${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} --gateway $PUBLIC_NETWORK_GATEWAY --name $PUBLIC_SUBNET_NAME $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
364 neutron router-gateway-set $ROUTER_ID $EXT_NET_ID
365
366 if is_service_enabled q-l3; then
367 # logic is specific to using the l3-agent for l3
368 if is_neutron_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
369 CIDR_LEN=${FLOATING_RANGE#*/}
370 sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
371 sudo ip link set $PUBLIC_BRIDGE up
372 ROUTER_GW_IP=`neutron port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
373 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
374 fi
375 if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
376 # Explicitly set router id in l3 agent configuration
377 iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
378 fi
379 fi
Sean Dague3bdb9222013-10-22 08:36:16 -0400380 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400381}
382
383# init_neutron() - Initialize databases, etc.
384function init_neutron() {
Salvatore Orlandodd649882013-08-05 08:56:17 -0700385 recreate_database $Q_DB_NAME utf8
386 # Run Neutron db migrations
387 $NEUTRON_BIN_DIR/neutron-db-manage --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE upgrade head
Mark McClainb05c8762013-07-06 23:29:39 -0400388}
389
390# install_neutron() - Collect source and prepare
391function install_neutron() {
392 git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH
393 setup_develop $NEUTRON_DIR
394}
395
396# install_neutronclient() - Collect source and prepare
397function install_neutronclient() {
398 git_clone $NEUTRONCLIENT_REPO $NEUTRONCLIENT_DIR $NEUTRONCLIENT_BRANCH
399 setup_develop $NEUTRONCLIENT_DIR
Attila Fazekasfac533e2013-08-14 16:04:01 +0200400 sudo install -D -m 0644 -o $STACK_USER {$NEUTRONCLIENT_DIR/tools/,/etc/bash_completion.d/}neutron.bash_completion
Mark McClainb05c8762013-07-06 23:29:39 -0400401}
402
403# install_neutron_agent_packages() - Collect source and prepare
404function install_neutron_agent_packages() {
405 # install packages that are specific to plugin agent(s)
406 if is_service_enabled q-agt q-dhcp q-l3; then
407 neutron_plugin_install_agent_packages
408 fi
409
410 if is_service_enabled q-lbaas; then
Sean Dague3bdb9222013-10-22 08:36:16 -0400411 neutron_agent_lbaas_install_agent_packages
Mark McClainb05c8762013-07-06 23:29:39 -0400412 fi
413}
414
415# Start running processes, including screen
416function start_neutron_service_and_check() {
417 # build config-file options
418 local cfg_file
419 local CFG_FILE_OPTIONS="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE"
420 for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do
Sean Dague3bdb9222013-10-22 08:36:16 -0400421 CFG_FILE_OPTIONS+=" --config-file /$cfg_file"
Mark McClainb05c8762013-07-06 23:29:39 -0400422 done
423 # Start the Neutron service
424 screen_it q-svc "cd $NEUTRON_DIR && python $NEUTRON_BIN_DIR/neutron-server $CFG_FILE_OPTIONS"
425 echo "Waiting for Neutron to start..."
JUN JIE NAN0aa85342013-09-13 15:47:09 +0800426 if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget --no-proxy -q -O- http://$Q_HOST:$Q_PORT; do sleep 1; done"; then
Sean Dague3bdb9222013-10-22 08:36:16 -0400427 die $LINENO "Neutron did not start"
Mark McClainb05c8762013-07-06 23:29:39 -0400428 fi
429}
430
431# Start running processes, including screen
432function start_neutron_agents() {
433 # Start up the neutron agents if enabled
434 screen_it q-agt "cd $NEUTRON_DIR && python $AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE"
435 screen_it q-dhcp "cd $NEUTRON_DIR && python $AGENT_DHCP_BINARY --config-file $NEUTRON_CONF --config-file=$Q_DHCP_CONF_FILE"
Nachi Ueno584750f2013-07-15 18:22:21 -0700436
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700437 L3_CONF_FILES="--config-file $NEUTRON_CONF --config-file=$Q_L3_CONF_FILE"
438
439 if is_service_enabled q-fwaas; then
440 L3_CONF_FILES="$L3_CONF_FILES --config-file $Q_FWAAS_CONF_FILE"
Nachi Ueno584750f2013-07-15 18:22:21 -0700441 fi
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700442 if is_service_enabled q-vpn; then
443 screen_it q-vpn "cd $NEUTRON_DIR && $AGENT_VPN_BINARY $L3_CONF_FILES"
444 else
445 screen_it q-l3 "cd $NEUTRON_DIR && python $AGENT_L3_BINARY $L3_CONF_FILES"
446 fi
447
Mark McClainb05c8762013-07-06 23:29:39 -0400448 screen_it q-meta "cd $NEUTRON_DIR && python $AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file=$Q_META_CONF_FILE"
449
450 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
451 # For XenServer, start an agent for the domU openvswitch
452 screen_it q-domua "cd $NEUTRON_DIR && python $AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE.domU"
453 fi
454
455 if is_service_enabled q-lbaas; then
456 screen_it q-lbaas "cd $NEUTRON_DIR && python $AGENT_LBAAS_BINARY --config-file $NEUTRON_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME"
457 fi
458}
459
460# stop_neutron() - Stop running processes (non-screen)
461function stop_neutron() {
462 if is_service_enabled q-dhcp; then
463 pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }')
464 [ ! -z "$pid" ] && sudo kill -9 $pid
465 fi
466 if is_service_enabled q-meta; then
467 pid=$(ps aux | awk '/neutron-ns-metadata-proxy/ { print $2 }')
468 [ ! -z "$pid" ] && sudo kill -9 $pid
469 fi
470}
471
472# cleanup_neutron() - Remove residual data files, anything left over from previous
473# runs that a clean run would need to clean up
474function cleanup_neutron() {
475 if is_neutron_ovs_base_plugin; then
476 neutron_ovs_base_cleanup
477 fi
478
479 # delete all namespaces created by neutron
480 for ns in $(sudo ip netns list | grep -o -e qdhcp-[0-9a-f\-]* -e qrouter-[0-9a-f\-]*); do
481 sudo ip netns delete ${ns}
482 done
483}
484
485# _configure_neutron_common()
486# Set common config for all neutron server and agents.
487# This MUST be called before other ``_configure_neutron_*`` functions.
488function _configure_neutron_common() {
489 # Put config files in ``NEUTRON_CONF_DIR`` for everyone to find
490 if [[ ! -d $NEUTRON_CONF_DIR ]]; then
491 sudo mkdir -p $NEUTRON_CONF_DIR
492 fi
493 sudo chown $STACK_USER $NEUTRON_CONF_DIR
494
495 cp $NEUTRON_DIR/etc/neutron.conf $NEUTRON_CONF
496
497 # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``.
498 # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``.
499 # For addition plugin config files, set ``Q_PLUGIN_EXTRA_CONF_PATH``,
500 # ``Q_PLUGIN_EXTRA_CONF_FILES``. For example:
Adam Spierscb961592013-10-05 12:11:07 +0100501 #
Mark McClainb05c8762013-07-06 23:29:39 -0400502 # ``Q_PLUGIN_EXTRA_CONF_FILES=(file1, file2)``
503 neutron_plugin_configure_common
504
sbauzae2c4ee22013-08-29 17:29:46 +0200505 if [[ "$Q_PLUGIN_CONF_PATH" == '' || "$Q_PLUGIN_CONF_FILENAME" == '' || "$Q_PLUGIN_CLASS" == '' ]]; then
Mark McClainb05c8762013-07-06 23:29:39 -0400506 die $LINENO "Neutron plugin not set.. exiting"
507 fi
508
509 # If needed, move config file from ``$NEUTRON_DIR/etc/neutron`` to ``NEUTRON_CONF_DIR``
510 mkdir -p /$Q_PLUGIN_CONF_PATH
511 Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
512 cp $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
513
514 iniset /$Q_PLUGIN_CONF_FILE database connection `database_connection_url $Q_DB_NAME`
515 iniset $NEUTRON_CONF DEFAULT state_path $DATA_DIR/neutron
516
517 # If addition config files are set, make sure their path name is set as well
518 if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 && $Q_PLUGIN_EXTRA_CONF_PATH == '' ]]; then
519 die $LINENO "Neutron additional plugin config not set.. exiting"
520 fi
521
522 # If additional config files exist, copy them over to neutron configuration
523 # directory
524 if [[ $Q_PLUGIN_EXTRA_CONF_PATH != '' ]]; then
525 mkdir -p /$Q_PLUGIN_EXTRA_CONF_PATH
526 local f
527 for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do
528 Q_PLUGIN_EXTRA_CONF_FILES[$f]=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
529 cp $NEUTRON_DIR/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} /${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
530 done
531 fi
532
Joe Gordonbee5c502013-08-30 13:48:08 -0400533 if [ "$VIRT_DRIVER" = 'fake' ]; then
534 # Disable arbitrary limits
535 iniset $NEUTRON_CONF quotas quota_network -1
536 iniset $NEUTRON_CONF quotas quota_subnet -1
537 iniset $NEUTRON_CONF quotas quota_port -1
538 iniset $NEUTRON_CONF quotas quota_security_group -1
539 iniset $NEUTRON_CONF quotas quota_security_group_rule -1
540 fi
541
Salvatore Orlando05ae8332013-08-20 14:51:08 -0700542 # Format logging
543 if [ "$LOG_COLOR" == "True" ] && [ "$SYSLOG" == "False" ]; then
544 setup_colorized_logging $NEUTRON_CONF DEFAULT
545 fi
546
Mark McClainb05c8762013-07-06 23:29:39 -0400547 _neutron_setup_rootwrap
548}
549
550function _configure_neutron_debug_command() {
551 if [[ "$Q_USE_DEBUG_COMMAND" != "True" ]]; then
552 return
553 fi
554
555 cp $NEUTRON_DIR/etc/l3_agent.ini $NEUTRON_TEST_CONFIG_FILE
556
557 iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT verbose False
558 iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT debug False
559 iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
560 iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND"
561 # Intermediate fix until Neutron patch lands and then line above will
562 # be cleaned.
563 iniset $NEUTRON_TEST_CONFIG_FILE agent root_helper "$Q_RR_COMMAND"
564
Mark McClainb05c8762013-07-06 23:29:39 -0400565 _neutron_setup_interface_driver $NEUTRON_TEST_CONFIG_FILE
566
567 neutron_plugin_configure_debug_command
568}
569
570function _configure_neutron_dhcp_agent() {
571 AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent"
572 Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini
573
574 cp $NEUTRON_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE
575
576 iniset $Q_DHCP_CONF_FILE DEFAULT verbose True
Ben Nemec03997942013-08-10 09:56:16 -0500577 iniset $Q_DHCP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400578 iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
579 iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
580
Kyle Mestery73b21912013-08-22 11:25:21 +0000581 # Define extra "DEFAULT" configuration options when q-dhcp is configured by
582 # defining the array ``Q_DHCP_EXTRA_DEFAULT_OPTS``.
583 # For Example: ``Q_DHCP_EXTRA_DEFAULT_OPTS=(foo=true bar=2)``
584 for I in "${Q_DHCP_EXTRA_DEFAULT_OPTS[@]}"; do
585 # Replace the first '=' with ' ' for iniset syntax
586 iniset $Q_DHCP_CONF_FILE DEFAULT ${I/=/ }
587 done
588
Mark McClainb05c8762013-07-06 23:29:39 -0400589 _neutron_setup_interface_driver $Q_DHCP_CONF_FILE
590
591 neutron_plugin_configure_dhcp_agent
592}
593
594function _configure_neutron_l3_agent() {
595 Q_L3_ENABLED=True
596 # for l3-agent, only use per tenant router if we have namespaces
597 Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE
Nachi Ueno69b3ff62013-06-07 10:28:33 -0700598
599 AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"}
Mark McClainb05c8762013-07-06 23:29:39 -0400600 Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini
601
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700602 if is_service_enabled q-fwaas; then
603 Q_FWAAS_CONF_FILE=$NEUTRON_CONF_DIR/fwaas_driver.ini
604 fi
605
Mark McClainb05c8762013-07-06 23:29:39 -0400606 cp $NEUTRON_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
607
608 iniset $Q_L3_CONF_FILE DEFAULT verbose True
Ben Nemec03997942013-08-10 09:56:16 -0500609 iniset $Q_L3_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400610 iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
611 iniset $Q_L3_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
612
Mark McClainb05c8762013-07-06 23:29:39 -0400613 _neutron_setup_interface_driver $Q_L3_CONF_FILE
614
615 neutron_plugin_configure_l3_agent
616}
617
618function _configure_neutron_metadata_agent() {
619 AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent"
620 Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini
621
622 cp $NEUTRON_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE
623
624 iniset $Q_META_CONF_FILE DEFAULT verbose True
Ben Nemec03997942013-08-10 09:56:16 -0500625 iniset $Q_META_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400626 iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
627 iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
628
Yong Sheng Gong8535d8b2013-08-25 11:21:13 +0800629 _neutron_setup_keystone $Q_META_CONF_FILE DEFAULT True True True
Maru Newbybf10ac52013-08-10 21:27:54 +0000630
Mark McClainb05c8762013-07-06 23:29:39 -0400631}
632
633function _configure_neutron_lbaas() {
634 neutron_agent_lbaas_configure_common
635 neutron_agent_lbaas_configure_agent
636}
637
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700638function _configure_neutron_fwaas() {
639 neutron_fwaas_configure_common
640 neutron_fwaas_configure_driver
641}
642
Nachi Ueno69b3ff62013-06-07 10:28:33 -0700643function _configure_neutron_vpn()
644{
645 neutron_vpn_install_agent_packages
646 neutron_vpn_configure_common
Nachi Ueno69b3ff62013-06-07 10:28:33 -0700647}
648
Mark McClainb05c8762013-07-06 23:29:39 -0400649# _configure_neutron_plugin_agent() - Set config files for neutron plugin agent
650# It is called when q-agt is enabled.
651function _configure_neutron_plugin_agent() {
652 # Specify the default root helper prior to agent configuration to
653 # ensure that an agent's configuration can override the default
654 iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND"
655 iniset $NEUTRON_CONF DEFAULT verbose True
Ben Nemec03997942013-08-10 09:56:16 -0500656 iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400657
658 # Configure agent for plugin
659 neutron_plugin_configure_plugin_agent
660}
661
662# _configure_neutron_service() - Set config files for neutron service
663# It is called when q-svc is enabled.
664function _configure_neutron_service() {
665 Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini
666 Q_POLICY_FILE=$NEUTRON_CONF_DIR/policy.json
667
668 cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
669 cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE
670
Mark McClainb05c8762013-07-06 23:29:39 -0400671 # Update either configuration file with plugin
672 iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
673
674 if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then
675 iniset $NEUTRON_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES
676 fi
677
678 iniset $NEUTRON_CONF DEFAULT verbose True
Ben Nemec03997942013-08-10 09:56:16 -0500679 iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400680 iniset $NEUTRON_CONF DEFAULT policy_file $Q_POLICY_FILE
681 iniset $NEUTRON_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP
682
683 iniset $NEUTRON_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
684 _neutron_setup_keystone $NEUTRON_CONF keystone_authtoken
685
Simon Pasquierca96b0a2013-07-09 16:59:12 +0200686 # Define extra "DEFAULT" configuration options when q-svc is configured by
687 # defining the array ``Q_SRV_EXTRA_DEFAULT_OPTS``.
688 # For Example: ``Q_SRV_EXTRA_DEFAULT_OPTS=(foo=true bar=2)``
689 for I in "${Q_SRV_EXTRA_DEFAULT_OPTS[@]}"; do
690 # Replace the first '=' with ' ' for iniset syntax
691 iniset $NEUTRON_CONF DEFAULT ${I/=/ }
692 done
693
Mark McClainb05c8762013-07-06 23:29:39 -0400694 # Configure plugin
695 neutron_plugin_configure_service
696}
697
698# Utility Functions
699#------------------
700
701# _neutron_setup_rootwrap() - configure Neutron's rootwrap
702function _neutron_setup_rootwrap() {
703 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
704 return
705 fi
706 # Deploy new rootwrap filters files (owned by root).
707 # Wipe any existing ``rootwrap.d`` files first
708 Q_CONF_ROOTWRAP_D=$NEUTRON_CONF_DIR/rootwrap.d
709 if [[ -d $Q_CONF_ROOTWRAP_D ]]; then
710 sudo rm -rf $Q_CONF_ROOTWRAP_D
711 fi
712 # Deploy filters to ``$NEUTRON_CONF_DIR/rootwrap.d``
713 mkdir -p -m 755 $Q_CONF_ROOTWRAP_D
714 cp -pr $NEUTRON_DIR/etc/neutron/rootwrap.d/* $Q_CONF_ROOTWRAP_D/
715 sudo chown -R root:root $Q_CONF_ROOTWRAP_D
716 sudo chmod 644 $Q_CONF_ROOTWRAP_D/*
717 # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d``
718 # location moved in newer versions, prefer new location
719 if test -r $NEUTRON_DIR/etc/neutron/rootwrap.conf; then
Sean Dague3bdb9222013-10-22 08:36:16 -0400720 sudo cp -p $NEUTRON_DIR/etc/neutron/rootwrap.conf $Q_RR_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400721 else
Sean Dague3bdb9222013-10-22 08:36:16 -0400722 sudo cp -p $NEUTRON_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400723 fi
724 sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE
725 sudo chown root:root $Q_RR_CONF_FILE
726 sudo chmod 0644 $Q_RR_CONF_FILE
727 # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap
728 ROOTWRAP_SUDOER_CMD="$NEUTRON_ROOTWRAP $Q_RR_CONF_FILE *"
729
730 # Set up the rootwrap sudoers for neutron
731 TEMPFILE=`mktemp`
732 echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
733 chmod 0440 $TEMPFILE
734 sudo chown root:root $TEMPFILE
735 sudo mv $TEMPFILE /etc/sudoers.d/neutron-rootwrap
736
737 # Update the root_helper
738 iniset $NEUTRON_CONF agent root_helper "$Q_RR_COMMAND"
739}
740
741# Configures keystone integration for neutron service and agents
742function _neutron_setup_keystone() {
743 local conf_file=$1
744 local section=$2
745 local use_auth_url=$3
Maru Newbybf10ac52013-08-10 21:27:54 +0000746 local skip_auth_cache=$4
Yong Sheng Gong8535d8b2013-08-25 11:21:13 +0800747 local use_service_port=$5
748 local keystone_port=$KEYSTONE_AUTH_PORT
749 if [[ -n $use_service_port ]]; then
750 keystone_port=$KEYSTONE_SERVICE_PORT
751 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400752 if [[ -n $use_auth_url ]]; then
Yong Sheng Gong8535d8b2013-08-25 11:21:13 +0800753 iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$keystone_port/v2.0"
Mark McClainb05c8762013-07-06 23:29:39 -0400754 else
755 iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST
Yong Sheng Gong8535d8b2013-08-25 11:21:13 +0800756 iniset $conf_file $section auth_port $keystone_port
Mark McClainb05c8762013-07-06 23:29:39 -0400757 iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL
758 fi
759 iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME
760 iniset $conf_file $section admin_user $Q_ADMIN_USERNAME
761 iniset $conf_file $section admin_password $SERVICE_PASSWORD
Maru Newbybf10ac52013-08-10 21:27:54 +0000762 if [[ -z $skip_auth_cache ]]; then
763 iniset $conf_file $section signing_dir $NEUTRON_AUTH_CACHE_DIR
764 # Create cache dir
765 sudo mkdir -p $NEUTRON_AUTH_CACHE_DIR
766 sudo chown $STACK_USER $NEUTRON_AUTH_CACHE_DIR
767 rm -f $NEUTRON_AUTH_CACHE_DIR/*
768 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400769}
770
771function _neutron_setup_interface_driver() {
772
773 # ovs_use_veth needs to be set before the plugin configuration
774 # occurs to allow plugins to override the setting.
775 iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH
776
777 neutron_plugin_setup_interface_driver $1
778}
779
780# Functions for Neutron Exercises
781#--------------------------------
782
783function delete_probe() {
784 local from_net="$1"
785 net_id=`_get_net_id $from_net`
786 probe_id=`neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-list -c id -c network_id | grep $net_id | awk '{print $2}'`
787 neutron-debug --os-tenant-name admin --os-username admin probe-delete $probe_id
788}
789
790function setup_neutron_debug() {
791 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
792 public_net_id=`_get_net_id $PUBLIC_NETWORK_NAME`
793 neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $public_net_id
794 private_net_id=`_get_net_id $PRIVATE_NETWORK_NAME`
795 neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $private_net_id
796 fi
797}
798
799function teardown_neutron_debug() {
800 delete_probe $PUBLIC_NETWORK_NAME
801 delete_probe $PRIVATE_NETWORK_NAME
802}
803
804function _get_net_id() {
805 neutron --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}'
806}
807
808function _get_probe_cmd_prefix() {
809 local from_net="$1"
810 net_id=`_get_net_id $from_net`
811 probe_id=`neutron-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-list -c id -c network_id | grep $net_id | awk '{print $2}' | head -n 1`
812 echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id"
813}
814
815function _ping_check_neutron() {
816 local from_net=$1
817 local ip=$2
818 local timeout_sec=$3
819 local expected=${4:-"True"}
820 local check_command=""
821 probe_cmd=`_get_probe_cmd_prefix $from_net`
822 if [[ "$expected" = "True" ]]; then
823 check_command="while ! $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
824 else
825 check_command="while $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
826 fi
827 if ! timeout $timeout_sec sh -c "$check_command"; then
828 if [[ "$expected" = "True" ]]; then
829 die $LINENO "[Fail] Couldn't ping server"
830 else
831 die $LINENO "[Fail] Could ping server"
832 fi
833 fi
834}
835
836# ssh check
837function _ssh_check_neutron() {
838 local from_net=$1
839 local key_file=$2
840 local ip=$3
841 local user=$4
842 local timeout_sec=$5
843 local probe_cmd = ""
844 probe_cmd=`_get_probe_cmd_prefix $from_net`
845 if ! timeout $timeout_sec sh -c "while ! $probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success; do sleep 1; done"; then
846 die $LINENO "server didn't become ssh-able!"
847 fi
848}
849
850# Neutron 3rd party programs
851#---------------------------
852
853# please refer to ``lib/neutron_thirdparty/README.md`` for details
854NEUTRON_THIRD_PARTIES=""
855for f in $TOP_DIR/lib/neutron_thirdparty/*; do
Sean Dague3bdb9222013-10-22 08:36:16 -0400856 third_party=$(basename $f)
857 if is_service_enabled $third_party; then
858 source $TOP_DIR/lib/neutron_thirdparty/$third_party
859 NEUTRON_THIRD_PARTIES="$NEUTRON_THIRD_PARTIES,$third_party"
860 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400861done
862
863function _neutron_third_party_do() {
864 for third_party in ${NEUTRON_THIRD_PARTIES//,/ }; do
865 ${1}_${third_party}
866 done
867}
868
869# configure_neutron_third_party() - Set config files, create data dirs, etc
870function configure_neutron_third_party() {
871 _neutron_third_party_do configure
872}
873
874# init_neutron_third_party() - Initialize databases, etc.
875function init_neutron_third_party() {
876 _neutron_third_party_do init
877}
878
879# install_neutron_third_party() - Collect source and prepare
880function install_neutron_third_party() {
881 _neutron_third_party_do install
882}
883
884# start_neutron_third_party() - Start running processes, including screen
885function start_neutron_third_party() {
886 _neutron_third_party_do start
887}
888
889# stop_neutron_third_party - Stop running processes (non-screen)
890function stop_neutron_third_party() {
891 _neutron_third_party_do stop
892}
893
894
895# Restore xtrace
896$XTRACE
897
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100898# Tell emacs to use shell-script-mode
899## Local variables:
900## mode: shell-script
901## End: