blob: b381b642c6f495d24b69c2c9f2574d12de1fd886 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mark McClainb05c8762013-07-06 23:29:39 -04003# lib/neutron
Joe Gordon23946052014-01-15 21:42:32 +00004# functions - functions specific to neutron
Mark McClainb05c8762013-07-06 23:29:39 -04005
6# Dependencies:
7# ``functions`` file
8# ``DEST`` must be defined
Stephan Renatuse578eff2013-11-19 13:31:04 +01009# ``STACK_USER`` must be defined
Mark McClainb05c8762013-07-06 23:29:39 -040010
11# ``stack.sh`` calls the entry points in this order:
12#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010013# - install_neutron_agent_packages
YAMAMOTO Takashi1a669dc2015-02-05 11:54:12 +090014# - install_neutronclient
15# - install_neutron
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010016# - install_neutron_third_party
17# - configure_neutron
18# - init_neutron
19# - configure_neutron_third_party
20# - init_neutron_third_party
21# - start_neutron_third_party
22# - create_nova_conf_neutron
23# - start_neutron_service_and_check
YAMAMOTO Takashi1a669dc2015-02-05 11:54:12 +090024# - check_neutron_third_party_integration
yunhong jiang0d6e9922014-10-10 06:12:47 -070025# - start_neutron_agents
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010026# - create_neutron_initial_network
Mark McClainb05c8762013-07-06 23:29:39 -040027#
28# ``unstack.sh`` calls the entry points in this order:
29#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010030# - stop_neutron
yunhong jiang0d6e9922014-10-10 06:12:47 -070031# - stop_neutron_third_party
32# - cleanup_neutron
Mark McClainb05c8762013-07-06 23:29:39 -040033
34# Functions in lib/neutron are classified into the following categories:
35#
36# - entry points (called from stack.sh or unstack.sh)
37# - internal functions
38# - neutron exercises
39# - 3rd party programs
40
41
42# Neutron Networking
43# ------------------
44
45# Make sure that neutron is enabled in ``ENABLED_SERVICES``. If you want
46# to run Neutron on this host, make sure that q-svc is also in
47# ``ENABLED_SERVICES``.
48#
Mark McClainb05c8762013-07-06 23:29:39 -040049# See "Neutron Network Configuration" below for additional variables
50# that must be set in localrc for connectivity across hosts with
51# Neutron.
52#
53# With Neutron networking the NETWORK_MANAGER variable is ignored.
Mark McClainb05c8762013-07-06 23:29:39 -040054
John Davidge21529a52014-06-30 09:55:11 -040055# Settings
56# --------
57
Mark McClainb05c8762013-07-06 23:29:39 -040058
59# Neutron Network Configuration
60# -----------------------------
61
Matthew Treinishabde96a2016-05-12 19:26:20 -040062deprecated "Using lib/neutron-legacy is deprecated, and it will be removed in the future"
Armando Migliaccio7dbcfae2016-02-19 14:43:42 -080063
Rob Crittenden18d47782014-03-19 17:47:42 -040064if is_ssl_enabled_service "neutron" || is_service_enabled tls-proxy; then
65 Q_PROTOCOL="https"
66fi
67
68
Mark McClainb05c8762013-07-06 23:29:39 -040069# Set up default directories
Sean Daguee08ab102014-11-13 17:09:28 -050070GITDIR["python-neutronclient"]=$DEST/python-neutronclient
Sean Dague5cb19062014-11-01 01:37:45 +010071
Doug Wiegley93e682c2015-03-03 10:31:30 -070072
Mark McClainb05c8762013-07-06 23:29:39 -040073NEUTRON_DIR=$DEST/neutron
Kyle Mestery20b839f2014-12-08 06:17:27 +000074NEUTRON_FWAAS_DIR=$DEST/neutron-fwaas
Mark McClainb05c8762013-07-06 23:29:39 -040075NEUTRON_AUTH_CACHE_DIR=${NEUTRON_AUTH_CACHE_DIR:-/var/cache/neutron}
76
77# Support entry points installation of console scripts
78if [[ -d $NEUTRON_DIR/bin/neutron-server ]]; then
79 NEUTRON_BIN_DIR=$NEUTRON_DIR/bin
Sean Dague3bdb9222013-10-22 08:36:16 -040080else
81 NEUTRON_BIN_DIR=$(get_python_exec_prefix)
Mark McClainb05c8762013-07-06 23:29:39 -040082fi
83
84NEUTRON_CONF_DIR=/etc/neutron
85NEUTRON_CONF=$NEUTRON_CONF_DIR/neutron.conf
86export NEUTRON_TEST_CONFIG_FILE=${NEUTRON_TEST_CONFIG_FILE:-"$NEUTRON_CONF_DIR/debug.ini"}
87
Adam Gandelman7614d212014-08-11 14:27:50 -070088# Agent binaries. Note, binary paths for other agents are set in per-service
89# scripts in lib/neutron_plugins/services/
90AGENT_DHCP_BINARY="$NEUTRON_BIN_DIR/neutron-dhcp-agent"
91AGENT_L3_BINARY=${AGENT_L3_BINARY:-"$NEUTRON_BIN_DIR/neutron-l3-agent"}
92AGENT_META_BINARY="$NEUTRON_BIN_DIR/neutron-metadata-agent"
93
94# Agent config files. Note, plugin-specific Q_PLUGIN_CONF_FILE is set and
95# loaded from per-plugin scripts in lib/neutron_plugins/
96Q_DHCP_CONF_FILE=$NEUTRON_CONF_DIR/dhcp_agent.ini
97Q_L3_CONF_FILE=$NEUTRON_CONF_DIR/l3_agent.ini
Adam Gandelman7614d212014-08-11 14:27:50 -070098Q_META_CONF_FILE=$NEUTRON_CONF_DIR/metadata_agent.ini
99
Henry Gessau0fc1cc22014-07-06 22:54:34 -0400100# Default name for Neutron database
101Q_DB_NAME=${Q_DB_NAME:-neutron}
Mark McClainb05c8762013-07-06 23:29:39 -0400102# Default Neutron Plugin
Kyle Mestery6d235002013-09-18 20:27:08 +0000103Q_PLUGIN=${Q_PLUGIN:-ml2}
Mark McClainb05c8762013-07-06 23:29:39 -0400104# Default Neutron Port
105Q_PORT=${Q_PORT:-9696}
Rob Crittenden18d47782014-03-19 17:47:42 -0400106# Default Neutron Internal Port when using TLS proxy
107Q_PORT_INT=${Q_PORT_INT:-19696}
Mark McClainb05c8762013-07-06 23:29:39 -0400108# Default Neutron Host
109Q_HOST=${Q_HOST:-$SERVICE_HOST}
Rob Crittenden18d47782014-03-19 17:47:42 -0400110# Default protocol
111Q_PROTOCOL=${Q_PROTOCOL:-$SERVICE_PROTOCOL}
Brian Haley180f5eb2015-06-16 13:14:31 -0400112# Default listen address
113Q_LISTEN_ADDRESS=${Q_LISTEN_ADDRESS:-$SERVICE_LISTEN_ADDRESS}
Mark McClainb05c8762013-07-06 23:29:39 -0400114# Default admin username
115Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-neutron}
116# Default auth strategy
117Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
Mark McClainb05c8762013-07-06 23:29:39 -0400118# RHEL's support for namespaces requires using veths with ovs
119Q_OVS_USE_VETH=${Q_OVS_USE_VETH:-False}
120Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
Yuriy Taraday26623952014-07-16 17:41:53 +0400121Q_USE_ROOTWRAP_DAEMON=$(trueorfalse True Q_USE_ROOTWRAP_DAEMON)
Mark McClainb05c8762013-07-06 23:29:39 -0400122# Meta data IP
123Q_META_DATA_IP=${Q_META_DATA_IP:-$SERVICE_HOST}
124# Allow Overlapping IP among subnets
125Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True}
Terry Wilsonf06c4432014-05-20 10:54:51 -0500126Q_NOTIFY_NOVA_PORT_STATUS_CHANGES=${Q_NOTIFY_NOVA_PORT_STATUS_CHANGES:-True}
127Q_NOTIFY_NOVA_PORT_DATA_CHANGES=${Q_NOTIFY_NOVA_PORT_DATA_CHANGES:-True}
Aaron Rosencea32b12014-03-04 16:20:14 -0800128VIF_PLUGGING_IS_FATAL=${VIF_PLUGGING_IS_FATAL:-True}
129VIF_PLUGGING_TIMEOUT=${VIF_PLUGGING_TIMEOUT:-300}
Aaron Rosen4540d002013-10-24 13:59:33 -0700130
YAMAMOTO Takashieede9dd2016-07-15 10:27:53 +0900131# The directory which contains files for Q_PLUGIN_EXTRA_CONF_FILES.
132# /etc/neutron is assumed by many of devstack plugins. Do not change.
133_Q_PLUGIN_EXTRA_CONF_PATH=/etc/neutron
134
Mark McClainb05c8762013-07-06 23:29:39 -0400135# List of config file names in addition to the main plugin config file
YAMAMOTO Takashieede9dd2016-07-15 10:27:53 +0900136# To add additional plugin config files, use ``neutron_server_config_add``
137# utility function. For example:
138#
139# ``neutron_server_config_add file1``
140#
141# These config files are relative to ``/etc/neutron``. The above
142# example would specify ``--config-file /etc/neutron/file1`` for
143# neutron server.
Mark McClainb05c8762013-07-06 23:29:39 -0400144declare -a Q_PLUGIN_EXTRA_CONF_FILES
145
YAMAMOTO Takashieede9dd2016-07-15 10:27:53 +0900146# same as Q_PLUGIN_EXTRA_CONF_FILES, but with absolute path.
147declare -a _Q_PLUGIN_EXTRA_CONF_FILES_ABS
148
Mark McClainb05c8762013-07-06 23:29:39 -0400149
Dean Troyere2907b42014-02-26 17:35:37 -0600150Q_RR_CONF_FILE=$NEUTRON_CONF_DIR/rootwrap.conf
151if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
152 Q_RR_COMMAND="sudo"
153else
154 NEUTRON_ROOTWRAP=$(get_rootwrap_location neutron)
155 Q_RR_COMMAND="sudo $NEUTRON_ROOTWRAP $Q_RR_CONF_FILE"
Yuriy Taraday26623952014-07-16 17:41:53 +0400156 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
157 Q_RR_DAEMON_COMMAND="sudo $NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE"
158 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400159fi
160
Brian Haleyeea76212014-06-27 11:45:50 -0400161
162# Distributed Virtual Router (DVR) configuration
163# Can be:
Dean Troyer3324f192014-09-18 09:26:39 -0500164# - ``legacy`` - No DVR functionality
165# - ``dvr_snat`` - Controller or single node DVR
166# - ``dvr`` - Compute node in multi-node DVR
167#
Brian Haleyeea76212014-06-27 11:45:50 -0400168Q_DVR_MODE=${Q_DVR_MODE:-legacy}
169if [[ "$Q_DVR_MODE" != "legacy" ]]; then
170 Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch,linuxbridge,l2population
171fi
172
Dean Troyere2907b42014-02-26 17:35:37 -0600173# Provider Network Configurations
174# --------------------------------
175
YAMAMOTO Takashi15130cd2014-10-28 11:49:58 +0900176# The following variables control the Neutron ML2 plugins' allocation
177# of tenant networks and availability of provider networks. If these
178# are not configured in ``localrc``, tenant networks will be local to
179# the host (with no remote connectivity), and no physical resources
180# will be available for the allocation of provider networks.
Dean Troyere2907b42014-02-26 17:35:37 -0600181
Attila Fazekas8feaf6c2014-07-27 20:47:04 +0200182# To disable tunnels (GRE or VXLAN) for tenant networks,
183# set to False in ``local.conf``.
184# GRE tunnels are only supported by the openvswitch.
185ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-True}
Dean Troyere2907b42014-02-26 17:35:37 -0600186
Richard Theis8906b482016-06-08 10:28:37 -0500187# If using GRE, VXLAN or GENEVE tunnels for tenant networks,
188# specify the range of IDs from which tenant networks are
189# allocated. Can be overridden in ``localrc`` if necessary.
Anant Patil3827dc02014-07-03 21:38:16 +0530190TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGES:-1:1000}
Dean Troyere2907b42014-02-26 17:35:37 -0600191
192# To use VLANs for tenant networks, set to True in localrc. VLANs
YAMAMOTO Takashi15130cd2014-10-28 11:49:58 +0900193# are supported by the ML2 plugins, requiring additional configuration
194# described below.
Dean Troyere2907b42014-02-26 17:35:37 -0600195ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False}
196
197# If using VLANs for tenant networks, set in ``localrc`` to specify
198# the range of VLAN VIDs from which tenant networks are
199# allocated. An external network switch must be configured to
200# trunk these VLANs between hosts for multi-host connectivity.
201#
202# Example: ``TENANT_VLAN_RANGE=1000:1999``
203TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-}
204
205# If using VLANs for tenant networks, or if using flat or VLAN
206# provider networks, set in ``localrc`` to the name of the physical
207# network, and also configure ``OVS_PHYSICAL_BRIDGE`` for the
208# openvswitch agent or ``LB_PHYSICAL_INTERFACE`` for the linuxbridge
209# agent, as described below.
210#
211# Example: ``PHYSICAL_NETWORK=default``
Kevin Benton1554ade2016-07-22 09:40:19 -0700212PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-public}
Dean Troyere2907b42014-02-26 17:35:37 -0600213
YAMAMOTO Takashi15130cd2014-10-28 11:49:58 +0900214# With the openvswitch agent, if using VLANs for tenant networks,
Dean Troyere2907b42014-02-26 17:35:37 -0600215# or if using flat or VLAN provider networks, set in ``localrc`` to
216# the name of the OVS bridge to use for the physical network. The
217# bridge will be created if it does not already exist, but a
218# physical interface must be manually added to the bridge as a
219# port for external connectivity.
220#
221# Example: ``OVS_PHYSICAL_BRIDGE=br-eth1``
Kevin Benton1554ade2016-07-22 09:40:19 -0700222OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-br-ex}
Dean Troyere2907b42014-02-26 17:35:37 -0600223
Clark Boylan95469032016-09-08 17:08:36 -0700224default_route_dev=$(ip route | grep ^default | awk '{print $5}')
225die_if_not_set $LINENO default_route_dev "Failure retrieving default route device"
YAMAMOTO Takashi15130cd2014-10-28 11:49:58 +0900226# With the linuxbridge agent, if using VLANs for tenant networks,
Dean Troyere2907b42014-02-26 17:35:37 -0600227# or if using flat or VLAN provider networks, set in ``localrc`` to
228# the name of the network interface to use for the physical
229# network.
230#
231# Example: ``LB_PHYSICAL_INTERFACE=eth1``
Clark Boylan95469032016-09-08 17:08:36 -0700232LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-$default_route_dev}
Dean Troyere2907b42014-02-26 17:35:37 -0600233
Edgar Magana6f335b92014-07-10 15:42:44 -0700234# When Neutron tunnels are enabled it is needed to specify the
235# IP address of the end point in the local server. This IP is set
236# by default to the same IP address that the HOST IP.
237# This variable can be used to specify a different end point IP address
238# Example: ``TUNNEL_ENDPOINT_IP=1.1.1.1``
239TUNNEL_ENDPOINT_IP=${TUNNEL_ENDPOINT_IP:-$HOST_IP}
240
Dean Troyere2907b42014-02-26 17:35:37 -0600241# With the openvswitch plugin, set to True in ``localrc`` to enable
242# provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False.
243#
244# Example: ``OVS_ENABLE_TUNNELING=True``
245OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
246
Tan Lin27a196e2014-10-31 15:44:34 +0800247# Use DHCP agent for providing metadata service in the case of
248# without L3 agent (No Route Agent), set to True in localrc.
249ENABLE_ISOLATED_METADATA=${ENABLE_ISOLATED_METADATA:-False}
250
251# Add a static route as dhcp option, so the request to 169.254.169.254
252# will be able to reach through a route(DHCP agent)
253# This option require ENABLE_ISOLATED_METADATA = True
254ENABLE_METADATA_NETWORK=${ENABLE_METADATA_NETWORK:-False}
Mark McClainb05c8762013-07-06 23:29:39 -0400255# Neutron plugin specific functions
256# ---------------------------------
257
258# Please refer to ``lib/neutron_plugins/README.md`` for details.
Hirofumi Ichihara36daecd2015-07-23 17:50:40 +0900259if [ -f $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN ]; then
260 source $TOP_DIR/lib/neutron_plugins/$Q_PLUGIN
261fi
Mark McClainb05c8762013-07-06 23:29:39 -0400262
Emilien Macchi40546f72013-09-24 15:10:25 +0200263# Agent metering service plugin functions
264# -------------------------------------------
265
266# Hardcoding for 1 service plugin for now
267source $TOP_DIR/lib/neutron_plugins/services/metering
268
Sean M. Collins2a242512016-05-03 09:03:09 -0400269# L3 Service functions
270source $TOP_DIR/lib/neutron_plugins/services/l3
Mark McClainb05c8762013-07-06 23:29:39 -0400271# Use security group or not
272if has_neutron_plugin_security_group; then
273 Q_USE_SECGROUP=${Q_USE_SECGROUP:-True}
274else
275 Q_USE_SECGROUP=False
276fi
277
Dean Troyere2907b42014-02-26 17:35:37 -0600278# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +1100279_XTRACE_NEUTRON=$(set +o | grep xtrace)
Dean Troyere2907b42014-02-26 17:35:37 -0600280set +o xtrace
281
282
Mark McClainb05c8762013-07-06 23:29:39 -0400283# Functions
284# ---------
285
Adam Gandelman7614d212014-08-11 14:27:50 -0700286function _determine_config_server {
YAMAMOTO Takashieede9dd2016-07-15 10:27:53 +0900287 if [[ "$Q_PLUGIN_EXTRA_CONF_PATH" != '' ]]; then
288 if [[ "$Q_PLUGIN_EXTRA_CONF_PATH" = "$_Q_PLUGIN_EXTRA_CONF_PATH" ]]; then
289 deprecated "Q_PLUGIN_EXTRA_CONF_PATH is deprecated"
290 else
291 die $LINENO "Q_PLUGIN_EXTRA_CONF_PATH is deprecated"
292 fi
293 fi
294 if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 ]]; then
295 deprecated "Q_PLUGIN_EXTRA_CONF_FILES is deprecated. Use neutron_server_config_add instead."
296 fi
297 for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do
298 _Q_PLUGIN_EXTRA_CONF_FILES_ABS+=($_Q_PLUGIN_EXTRA_CONF_PATH/$cfg_file)
299 done
300
Adam Gandelman7614d212014-08-11 14:27:50 -0700301 local cfg_file
302 local opts="--config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE"
YAMAMOTO Takashieede9dd2016-07-15 10:27:53 +0900303 for cfg_file in ${_Q_PLUGIN_EXTRA_CONF_FILES_ABS[@]}; do
Tom Patzig73467042016-04-19 17:02:34 +0200304 opts+=" --config-file $cfg_file"
Adam Gandelman7614d212014-08-11 14:27:50 -0700305 done
306 echo "$opts"
307}
308
Adam Gandelman7614d212014-08-11 14:27:50 -0700309function _determine_config_l3 {
Angus Leesa1c70f22016-05-31 14:43:14 +1000310 local opts="--config-file $NEUTRON_CONF --config-file $Q_L3_CONF_FILE"
Adam Gandelman7614d212014-08-11 14:27:50 -0700311 echo "$opts"
312}
313
314# For services and agents that require it, dynamically construct a list of
315# --config-file arguments that are passed to the binary.
316function determine_config_files {
317 local opts=""
318 case "$1" in
319 "neutron-server") opts="$(_determine_config_server)" ;;
Adam Gandelman7614d212014-08-11 14:27:50 -0700320 "neutron-l3-agent") opts="$(_determine_config_l3)" ;;
321 esac
322 if [ -z "$opts" ] ; then
323 die $LINENO "Could not determine config files for $1."
324 fi
325 echo "$opts"
326}
327
Sean M. Collins2a242512016-05-03 09:03:09 -0400328# configure_mutnauq()
Mark McClainb05c8762013-07-06 23:29:39 -0400329# Set common config for all neutron server and agents.
Sean M. Collins2a242512016-05-03 09:03:09 -0400330function configure_mutnauq {
Mark McClainb05c8762013-07-06 23:29:39 -0400331 _configure_neutron_common
Brant Knudson2dd110c2015-03-14 12:39:14 -0500332 iniset_rpc_backend neutron $NEUTRON_CONF
Mark McClainb05c8762013-07-06 23:29:39 -0400333
334 # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES
Emilien Macchi40546f72013-09-24 15:10:25 +0200335 if is_service_enabled q-metering; then
336 _configure_neutron_metering
337 fi
Stephen Ma9b38eb22014-04-02 02:13:09 +0000338 if is_service_enabled q-agt q-svc; then
Mark McClainb05c8762013-07-06 23:29:39 -0400339 _configure_neutron_service
340 fi
341 if is_service_enabled q-agt; then
342 _configure_neutron_plugin_agent
343 fi
344 if is_service_enabled q-dhcp; then
345 _configure_neutron_dhcp_agent
346 fi
347 if is_service_enabled q-l3; then
348 _configure_neutron_l3_agent
349 fi
350 if is_service_enabled q-meta; then
351 _configure_neutron_metadata_agent
352 fi
353
Brian Haleyeea76212014-06-27 11:45:50 -0400354 if [[ "$Q_DVR_MODE" != "legacy" ]]; then
355 _configure_dvr
356 fi
Dina Belova58adaa62014-07-11 18:18:12 +0400357 if is_service_enabled ceilometer; then
358 _configure_neutron_ceilometer_notifications
359 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400360
armando-migliaccioe155b892015-06-12 08:55:02 -0700361 iniset $NEUTRON_CONF DEFAULT api_workers "$API_WORKERS"
Armando Migliaccio06f2ea22017-02-02 16:47:00 -0800362 # devstack is not a tool for running uber scale OpenStack
363 # clouds, therefore running without a dedicated RPC worker
364 # for state reports is more than adequate.
365 iniset $NEUTRON_CONF DEFAULT rpc_state_report_workers 0
Mark McClainb05c8762013-07-06 23:29:39 -0400366}
367
Ian Wienandaee18c72014-02-21 15:35:08 +1100368function create_nova_conf_neutron {
Sean Daguef21cc1f2016-03-04 11:08:32 -0500369 iniset $NOVA_CONF DEFAULT use_neutron True
Matthew Kassawara28af7962016-02-10 19:04:08 +0000370 iniset $NOVA_CONF neutron auth_type "password"
Brant Knudsone86b91b2016-05-03 15:21:47 -0500371 iniset $NOVA_CONF neutron auth_url "$KEYSTONE_AUTH_URI/v3"
Jamie Lennox394968f2015-08-28 09:18:26 +1000372 iniset $NOVA_CONF neutron username "$Q_ADMIN_USERNAME"
373 iniset $NOVA_CONF neutron password "$SERVICE_PASSWORD"
Jamie Lennoxcbcbd8f2016-01-21 16:08:14 -0600374 iniset $NOVA_CONF neutron user_domain_name "$SERVICE_DOMAIN_NAME"
Sean Dague7580a0c2016-02-17 06:23:36 -0500375 iniset $NOVA_CONF neutron project_name "$SERVICE_PROJECT_NAME"
Jamie Lennoxcbcbd8f2016-01-21 16:08:14 -0600376 iniset $NOVA_CONF neutron project_domain_name "$SERVICE_DOMAIN_NAME"
Gary Kotton13d385e2014-06-17 23:24:53 -0700377 iniset $NOVA_CONF neutron auth_strategy "$Q_AUTH_STRATEGY"
Bartosz Górski0abde392014-02-28 14:15:19 +0100378 iniset $NOVA_CONF neutron region_name "$REGION_NAME"
Rob Crittenden18d47782014-03-19 17:47:42 -0400379 iniset $NOVA_CONF neutron url "${Q_PROTOCOL}://$Q_HOST:$Q_PORT"
Mark McClainb05c8762013-07-06 23:29:39 -0400380
381 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
382 LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
Jeff Peeler1143f7e2013-10-31 16:21:52 -0400383 iniset $NOVA_CONF DEFAULT firewall_driver $LIBVIRT_FIREWALL_DRIVER
Mark McClainb05c8762013-07-06 23:29:39 -0400384 fi
385
Matt Riedemann925c2562015-08-25 13:40:25 -0700386 # optionally set options in nova_conf
Mark McClainb05c8762013-07-06 23:29:39 -0400387 neutron_plugin_create_nova_conf
388
Mark McClainb05c8762013-07-06 23:29:39 -0400389 if is_service_enabled q-meta; then
Gary Kottondd745502014-08-11 23:38:47 -0700390 iniset $NOVA_CONF neutron service_metadata_proxy "True"
Mark McClainb05c8762013-07-06 23:29:39 -0400391 fi
Aaron Rosencea32b12014-03-04 16:20:14 -0800392
393 iniset $NOVA_CONF DEFAULT vif_plugging_is_fatal "$VIF_PLUGGING_IS_FATAL"
394 iniset $NOVA_CONF DEFAULT vif_plugging_timeout "$VIF_PLUGGING_TIMEOUT"
Mark McClainb05c8762013-07-06 23:29:39 -0400395}
396
Sean M. Collins2a242512016-05-03 09:03:09 -0400397# create_mutnauq_accounts() - Set up common required neutron accounts
Mark McClainb05c8762013-07-06 23:29:39 -0400398
399# Tenant User Roles
400# ------------------------------------------------------------------
401# service neutron admin # if enabled
402
403# Migrated from keystone_data.sh
Sean M. Collins2a242512016-05-03 09:03:09 -0400404function create_mutnauq_accounts {
Mark McClainb05c8762013-07-06 23:29:39 -0400405 if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
Bartosz Górski0abde392014-02-28 14:15:19 +0100406
Jamie Lennox85ff5322015-01-28 14:28:01 +1000407 create_service_user "neutron"
Bartosz Górski0abde392014-02-28 14:15:19 +0100408
Sean Dague985e9582016-02-10 07:25:24 -0500409 get_or_create_service "neutron" "network" "Neutron Service"
Matt Riedemannae4578b2016-04-23 01:45:40 +0000410 get_or_create_endpoint \
Sean Dague985e9582016-02-10 07:25:24 -0500411 "network" \
412 "$REGION_NAME" \
Sean Dague985e9582016-02-10 07:25:24 -0500413 "$Q_PROTOCOL://$SERVICE_HOST:$Q_PORT/"
Mark McClainb05c8762013-07-06 23:29:39 -0400414 fi
415}
416
Sean M. Collins2a242512016-05-03 09:03:09 -0400417# init_mutnauq() - Initialize databases, etc.
418function init_mutnauq {
Ihar Hrachyshka157c84b2014-10-06 13:29:39 +0200419 recreate_database $Q_DB_NAME
Salvatore Orlandodd649882013-08-05 08:56:17 -0700420 # Run Neutron db migrations
421 $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 -0400422}
423
Sean M. Collins2a242512016-05-03 09:03:09 -0400424# install_mutnauq() - Collect source and prepare
425function install_mutnauq {
Doug Wiegley86561c32016-02-10 18:37:21 -0700426 # Install neutron-lib from git so we make sure we're testing
427 # the latest code.
428 if use_library_from_git "neutron-lib"; then
429 git_clone_by_name "neutron-lib"
430 setup_dev_lib "neutron-lib"
431 fi
432
Mark McClainb05c8762013-07-06 23:29:39 -0400433 git_clone $NEUTRON_REPO $NEUTRON_DIR $NEUTRON_BRANCH
434 setup_develop $NEUTRON_DIR
Mate Lakat6df64892014-10-17 13:09:49 +0200435
436 if [ "$VIRT_DRIVER" == 'xenserver' ]; then
437 local dom0_ip
438 dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-)
439
440 local ssh_dom0
441 ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip"
442
443 # Find where the plugins should go in dom0
444 local xen_functions
445 xen_functions=$(cat $TOP_DIR/tools/xen/functions)
446 local plugin_dir
447 plugin_dir=$($ssh_dom0 "$xen_functions; set -eux; xapi_plugin_location")
448
449 # install neutron plugins to dom0
Huan Xie201e3c12015-08-27 12:34:24 +0100450 tar -czf - -C $NEUTRON_DIR/neutron/plugins/ml2/drivers/openvswitch/agent/xenapi/etc/xapi.d/plugins/ ./ |
Mate Lakat6df64892014-10-17 13:09:49 +0200451 $ssh_dom0 "tar -xzf - -C $plugin_dir && chmod a+x $plugin_dir/*"
452 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400453}
454
Mark McClainb05c8762013-07-06 23:29:39 -0400455# install_neutron_agent_packages() - Collect source and prepare
YAMAMOTO Takashic74315e2016-07-21 17:49:43 +0900456function install_neutron_agent_packages_mutnauq {
Robert Li72b3e442014-07-17 15:04:52 -0400457 # radvd doesn't come with the OS. Install it if the l3 service is enabled.
458 if is_service_enabled q-l3; then
459 install_package radvd
460 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400461 # install packages that are specific to plugin agent(s)
462 if is_service_enabled q-agt q-dhcp q-l3; then
463 neutron_plugin_install_agent_packages
464 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400465}
466
467# Start running processes, including screen
Ian Wienandaee18c72014-02-21 15:35:08 +1100468function start_neutron_service_and_check {
Rob Crittenden18d47782014-03-19 17:47:42 -0400469 local service_port=$Q_PORT
470 local service_protocol=$Q_PROTOCOL
Ian Wienand7ae97292016-02-16 14:50:53 +1100471 local cfg_file_options
472
473 cfg_file_options="$(determine_config_files neutron-server)"
474
Rob Crittenden18d47782014-03-19 17:47:42 -0400475 if is_service_enabled tls-proxy; then
476 service_port=$Q_PORT_INT
477 service_protocol="http"
478 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400479 # Start the Neutron service
Davanum Srinivas59756e92015-09-23 17:42:54 -0400480 run_process q-svc "$NEUTRON_BIN_DIR/neutron-server $cfg_file_options"
Mark McClainb05c8762013-07-06 23:29:39 -0400481 echo "Waiting for Neutron to start..."
Rob Crittenden18d47782014-03-19 17:47:42 -0400482 if is_ssl_enabled_service "neutron"; then
483 ssl_ca="--ca-certificate=${SSL_BUNDLE_FILE}"
484 fi
Sean Dague442e4e92015-06-24 13:24:02 -0400485
486 local testcmd="wget ${ssl_ca} --no-proxy -q -O- $service_protocol://$Q_HOST:$service_port"
487 test_with_retry "$testcmd" "Neutron did not start" $SERVICE_TIMEOUT
488
Rob Crittenden18d47782014-03-19 17:47:42 -0400489 # Start proxy if enabled
490 if is_service_enabled tls-proxy; then
Gregory Haynes4b49e402016-08-31 18:19:51 -0700491 start_tls_proxy neutron '*' $Q_PORT $Q_HOST $Q_PORT_INT
Rob Crittenden18d47782014-03-19 17:47:42 -0400492 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400493}
494
Russell Bryant09b94602015-06-08 15:25:43 -0400495# Control of the l2 agent is separated out to make it easier to test partial
496# upgrades (everything upgraded except the L2 agent)
Sean M. Collins2a242512016-05-03 09:03:09 -0400497function start_mutnauq_l2_agent {
Davanum Srinivas59756e92015-09-23 17:42:54 -0400498 run_process q-agt "$AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE"
Nachi Ueno584750f2013-07-15 18:22:21 -0700499
Kahou Leid663e292015-10-24 12:18:57 -0700500 if is_provider_network && [[ $Q_AGENT == "openvswitch" ]]; then
Zhongyue Luo56b7efb2014-12-16 11:36:49 +0800501 sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE
Sean M. Collins5ec6f8f2014-05-14 17:01:03 -0400502 sudo ip link set $OVS_PHYSICAL_BRIDGE up
503 sudo ip link set br-int up
504 sudo ip link set $PUBLIC_INTERFACE up
yunhong jiangae9ee6b2014-10-08 07:01:02 -0700505 if is_ironic_hardware; then
506 for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do
507 sudo ip addr del $IP dev $PUBLIC_INTERFACE
508 sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
509 done
gong yong sheng348c6ac2015-06-23 14:03:47 +0800510 sudo ip route replace $FIXED_RANGE via $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE
yunhong jiangae9ee6b2014-10-08 07:01:02 -0700511 fi
Sean M. Collins5ec6f8f2014-05-14 17:01:03 -0400512 fi
Russell Bryant09b94602015-06-08 15:25:43 -0400513}
514
Sean M. Collins2a242512016-05-03 09:03:09 -0400515function start_mutnauq_other_agents {
Angus Leesa1c70f22016-05-31 14:43:14 +1000516 run_process q-dhcp "$AGENT_DHCP_BINARY --config-file $NEUTRON_CONF --config-file $Q_DHCP_CONF_FILE"
Sean M. Collins5ec6f8f2014-05-14 17:01:03 -0400517
Paul Michalie4289c82015-08-14 11:49:27 -0400518 if is_service_enabled neutron-vpnaas; then
519 : # Started by plugin
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700520 else
Davanum Srinivas59756e92015-09-23 17:42:54 -0400521 run_process q-l3 "$AGENT_L3_BINARY $(determine_config_files neutron-l3-agent)"
Ravi Chunduru95c93e22013-07-16 04:18:47 -0700522 fi
523
Angus Leesa1c70f22016-05-31 14:43:14 +1000524 run_process q-meta "$AGENT_META_BINARY --config-file $NEUTRON_CONF --config-file $Q_META_CONF_FILE"
Davanum Srinivas59756e92015-09-23 17:42:54 -0400525 run_process q-metering "$AGENT_METERING_BINARY --config-file $NEUTRON_CONF --config-file $METERING_AGENT_CONF_FILENAME"
Mark McClainb05c8762013-07-06 23:29:39 -0400526
527 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
528 # For XenServer, start an agent for the domU openvswitch
Davanum Srinivas59756e92015-09-23 17:42:54 -0400529 run_process q-domua "$AGENT_BINARY --config-file $NEUTRON_CONF --config-file /$Q_PLUGIN_CONF_FILE.domU"
Mark McClainb05c8762013-07-06 23:29:39 -0400530 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400531}
532
Russell Bryant09b94602015-06-08 15:25:43 -0400533# Start running processes, including screen
534function start_neutron_agents {
535 # Start up the neutron agents if enabled
Sean M. Collins2a242512016-05-03 09:03:09 -0400536 start_mutnauq_l2_agent
537 start_mutnauq_other_agents
Russell Bryant09b94602015-06-08 15:25:43 -0400538}
539
Sean M. Collins2a242512016-05-03 09:03:09 -0400540function stop_mutnauq_l2_agent {
Russell Bryant09b94602015-06-08 15:25:43 -0400541 stop_process q-agt
Huan Xie54482cd2016-10-09 09:47:48 +0000542
543 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
544 stop_process q-domua
545 fi
Russell Bryant09b94602015-06-08 15:25:43 -0400546}
547
Sean M. Collins2a242512016-05-03 09:03:09 -0400548# stop_mutnauq_other() - Stop running processes (non-screen)
549function stop_mutnauq_other {
Mark McClainb05c8762013-07-06 23:29:39 -0400550 if is_service_enabled q-dhcp; then
Chris Dent36891dc2015-02-03 16:22:44 +0000551 stop_process q-dhcp
Mark McClainb05c8762013-07-06 23:29:39 -0400552 pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }')
553 [ ! -z "$pid" ] && sudo kill -9 $pid
554 fi
Chris Dent36891dc2015-02-03 16:22:44 +0000555
556 stop_process q-svc
Li Maa15d9de2016-01-19 19:11:51 +0800557
558 if is_service_enabled q-l3; then
559 sudo pkill -f "radvd -C $DATA_DIR/neutron/ra"
560 stop_process q-l3
561 fi
Chris Dent36891dc2015-02-03 16:22:44 +0000562
Mark McClainb05c8762013-07-06 23:29:39 -0400563 if is_service_enabled q-meta; then
Jakub Libosvar1f763282014-01-28 23:01:38 +0100564 sudo pkill -9 -f neutron-ns-metadata-proxy || :
Chris Dent36891dc2015-02-03 16:22:44 +0000565 stop_process q-meta
Mark McClainb05c8762013-07-06 23:29:39 -0400566 fi
Akihiro Motokiedddb1f2013-12-09 20:21:06 +0900567
Akihiro Motokiedddb1f2013-12-09 20:21:06 +0900568 if is_service_enabled q-metering; then
569 neutron_metering_stop
570 fi
Li Ma50120fa2015-12-13 10:41:34 +0800571
572 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
573 sudo pkill -9 -f $NEUTRON_ROOTWRAP-daemon || :
574 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400575}
576
Russell Bryant09b94602015-06-08 15:25:43 -0400577# stop_neutron() - Stop running processes (non-screen)
Sean M. Collins2a242512016-05-03 09:03:09 -0400578function stop_mutnauq {
579 stop_mutnauq_other
580 stop_mutnauq_l2_agent
Russell Bryant09b94602015-06-08 15:25:43 -0400581}
582
Sean M. Collins00e16a92015-02-20 11:45:21 -0500583# _move_neutron_addresses_route() - Move the primary IP to the OVS bridge
Adam Kacmarsky6b172c82015-08-13 15:14:05 -0600584# on startup, or back to the public interface on cleanup. If no IP is
585# configured on the interface, just add it as a port to the OVS bridge.
Sean M. Collins00e16a92015-02-20 11:45:21 -0500586function _move_neutron_addresses_route {
587 local from_intf=$1
588 local to_intf=$2
589 local add_ovs_port=$3
Brian Haleya0d1b012015-11-16 17:30:48 -0500590 local del_ovs_port=$4
591 local af=$5
Sean M. Collins00e16a92015-02-20 11:45:21 -0500592
593 if [[ -n "$from_intf" && -n "$to_intf" ]]; then
594 # Remove the primary IP address from $from_intf and add it to $to_intf,
595 # along with the default route, if it exists. Also, when called
596 # on configure we will also add $from_intf as a port on $to_intf,
597 # assuming it is an OVS bridge.
598
Matt McEuene24707b2016-07-11 08:37:59 -0500599 local IP_REPLACE=""
Adam Kacmarsky6b172c82015-08-13 15:14:05 -0600600 local IP_DEL=""
Shinobu KINJOf95315b2015-11-07 10:21:08 +0900601 local IP_UP=""
Ian Wienandada886d2015-10-07 14:06:26 +1100602 local DEFAULT_ROUTE_GW
Sean M. Collins59e86a32015-11-09 11:06:39 -0500603 DEFAULT_ROUTE_GW=$(ip -f $af r | awk "/default.+$from_intf/ { print \$3; exit }")
Sean M. Collins00e16a92015-02-20 11:45:21 -0500604 local ADD_OVS_PORT=""
Brian Haleya0d1b012015-11-16 17:30:48 -0500605 local DEL_OVS_PORT=""
Sean M. Collins17398a32016-05-11 18:24:46 +0000606 local ARP_CMD=""
Sean M. Collins00e16a92015-02-20 11:45:21 -0500607
Brian Haleybb9caea2015-11-16 17:18:42 -0500608 IP_BRD=$(ip -f $af a s dev $from_intf scope global primary | grep inet | awk '{ print $2, $3, $4; exit }')
Adam Kacmarsky11298a02015-06-26 14:49:47 -0600609
Sean M. Collins00e16a92015-02-20 11:45:21 -0500610 if [ "$DEFAULT_ROUTE_GW" != "" ]; then
Sean M. Collins59e86a32015-11-09 11:06:39 -0500611 ADD_DEFAULT_ROUTE="sudo ip -f $af r replace default via $DEFAULT_ROUTE_GW dev $to_intf"
Sean M. Collins00e16a92015-02-20 11:45:21 -0500612 fi
613
614 if [[ "$add_ovs_port" == "True" ]]; then
Raman Budnydb02bbf2015-03-31 13:09:09 +0300615 ADD_OVS_PORT="sudo ovs-vsctl --may-exist add-port $to_intf $from_intf"
Sean M. Collins00e16a92015-02-20 11:45:21 -0500616 fi
617
Brian Haleya0d1b012015-11-16 17:30:48 -0500618 if [[ "$del_ovs_port" == "True" ]]; then
619 DEL_OVS_PORT="sudo ovs-vsctl --if-exists del-port $from_intf $to_intf"
620 fi
621
Adam Kacmarsky6b172c82015-08-13 15:14:05 -0600622 if [[ "$IP_BRD" != "" ]]; then
Brian Haley94510212015-09-02 15:40:04 -0400623 IP_DEL="sudo ip addr del $IP_BRD dev $from_intf"
Matt McEuene24707b2016-07-11 08:37:59 -0500624 IP_REPLACE="sudo ip addr replace $IP_BRD dev $to_intf"
Shinobu KINJOf95315b2015-11-07 10:21:08 +0900625 IP_UP="sudo ip link set $to_intf up"
Sean M. Collins6d4843e2016-05-12 16:14:26 -0400626 if [[ "$af" == "inet" ]]; then
627 IP=$(echo $IP_BRD | awk '{ print $1; exit }' | grep -o -E '(.*)/' | cut -d "/" -f1)
628 ARP_CMD="arping -A -c 3 -w 4.5 -I $to_intf $IP "
629 fi
Adam Kacmarsky6b172c82015-08-13 15:14:05 -0600630 fi
631
Brian Haleya0d1b012015-11-16 17:30:48 -0500632 # The add/del OVS port calls have to happen either before or
633 # after the address is moved in order to not leave it orphaned.
Matt McEuene24707b2016-07-11 08:37:59 -0500634 $DEL_OVS_PORT; $IP_DEL; $IP_REPLACE; $IP_UP; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE; $ARP_CMD
Sean M. Collins00e16a92015-02-20 11:45:21 -0500635 fi
636}
637
Sean M. Collins2a242512016-05-03 09:03:09 -0400638# cleanup_mutnauq() - Remove residual data files, anything left over from previous
Mark McClainb05c8762013-07-06 23:29:39 -0400639# runs that a clean run would need to clean up
Sean M. Collins2a242512016-05-03 09:03:09 -0400640function cleanup_mutnauq {
Sean M. Collins00e16a92015-02-20 11:45:21 -0500641
Yalei Wang316b3482015-07-15 21:00:31 +0800642 if [[ -n "$OVS_PHYSICAL_BRIDGE" ]]; then
Brian Haleya0d1b012015-11-16 17:30:48 -0500643 _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False True "inet"
Adam Kacmarsky11298a02015-06-26 14:49:47 -0600644
Yalei Wang316b3482015-07-15 21:00:31 +0800645 if [[ $(ip -f inet6 a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then
Sean M. Collins790266f2015-11-11 13:36:35 -0500646 # ip(8) wants the prefix length when deleting
647 local v6_gateway
648 v6_gateway=$(ip -6 a s dev $OVS_PHYSICAL_BRIDGE | grep $IPV6_PUBLIC_NETWORK_GATEWAY | awk '{ print $2 }')
649 sudo ip -6 addr del $v6_gateway dev $OVS_PHYSICAL_BRIDGE
Brian Haleya0d1b012015-11-16 17:30:48 -0500650 _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False False "inet6"
Yalei Wang316b3482015-07-15 21:00:31 +0800651 fi
Sean M. Collins00e16a92015-02-20 11:45:21 -0500652
Yalei Wang316b3482015-07-15 21:00:31 +0800653 if is_provider_network && is_ironic_hardware; then
654 for IP in $(ip addr show dev $OVS_PHYSICAL_BRIDGE | grep ' inet ' | awk '{print $2}'); do
655 sudo ip addr del $IP dev $OVS_PHYSICAL_BRIDGE
656 sudo ip addr add $IP dev $PUBLIC_INTERFACE
657 done
658 sudo route del -net $FIXED_RANGE gw $NETWORK_GATEWAY dev $OVS_PHYSICAL_BRIDGE
659 fi
yunhong jiangae9ee6b2014-10-08 07:01:02 -0700660 fi
661
Mark McClainb05c8762013-07-06 23:29:39 -0400662 if is_neutron_ovs_base_plugin; then
663 neutron_ovs_base_cleanup
664 fi
665
Sean M. Collins7bc2af72015-06-08 12:36:30 -0400666 if [[ $Q_AGENT == "linuxbridge" ]]; then
667 neutron_lb_cleanup
668 fi
669
Mark McClainb05c8762013-07-06 23:29:39 -0400670 # delete all namespaces created by neutron
Doug Wiegley7e40c642016-08-20 16:32:14 +0000671 for ns in $(sudo ip netns list | grep -o -E '(qdhcp|qrouter|fip|snat)-[0-9a-f-]*'); do
Mark McClainb05c8762013-07-06 23:29:39 -0400672 sudo ip netns delete ${ns}
673 done
674}
675
Doug Wiegley93e682c2015-03-03 10:31:30 -0700676
Maru Newby952fd902015-01-30 22:27:12 +0000677function _create_neutron_conf_dir {
Mark McClainb05c8762013-07-06 23:29:39 -0400678 # Put config files in ``NEUTRON_CONF_DIR`` for everyone to find
Dean Troyer8421c2b2015-03-16 13:52:19 -0500679 sudo install -d -o $STACK_USER $NEUTRON_CONF_DIR
Maru Newby952fd902015-01-30 22:27:12 +0000680}
681
682# _configure_neutron_common()
683# Set common config for all neutron server and agents.
684# This MUST be called before other ``_configure_neutron_*`` functions.
685function _configure_neutron_common {
686 _create_neutron_conf_dir
Mark McClainb05c8762013-07-06 23:29:39 -0400687
Martin Hickey30d5fae2015-11-10 13:44:15 +0000688 # Uses oslo config generator to generate core sample configuration files
689 (cd $NEUTRON_DIR && exec ./tools/generate_config_file_samples.sh)
690
691 cp $NEUTRON_DIR/etc/neutron.conf.sample $NEUTRON_CONF
Mark McClainb05c8762013-07-06 23:29:39 -0400692
Jerry Zhao296c1e32015-08-07 20:43:54 -0400693 Q_POLICY_FILE=$NEUTRON_CONF_DIR/policy.json
694 cp $NEUTRON_DIR/etc/policy.json $Q_POLICY_FILE
695
696 # allow neutron user to administer neutron to match neutron account
697 sed -i 's/"context_is_admin": "role:admin"/"context_is_admin": "role:admin or user_name:neutron"/g' $Q_POLICY_FILE
698
Mark McClainb05c8762013-07-06 23:29:39 -0400699 # Set plugin-specific variables ``Q_DB_NAME``, ``Q_PLUGIN_CLASS``.
700 # For main plugin config file, set ``Q_PLUGIN_CONF_PATH``, ``Q_PLUGIN_CONF_FILENAME``.
Mark McClainb05c8762013-07-06 23:29:39 -0400701 neutron_plugin_configure_common
702
sbauzae2c4ee22013-08-29 17:29:46 +0200703 if [[ "$Q_PLUGIN_CONF_PATH" == '' || "$Q_PLUGIN_CONF_FILENAME" == '' || "$Q_PLUGIN_CLASS" == '' ]]; then
Mark McClainb05c8762013-07-06 23:29:39 -0400704 die $LINENO "Neutron plugin not set.. exiting"
705 fi
706
707 # If needed, move config file from ``$NEUTRON_DIR/etc/neutron`` to ``NEUTRON_CONF_DIR``
708 mkdir -p /$Q_PLUGIN_CONF_PATH
709 Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
Hirofumi Ichihara97cc85b2015-09-08 13:51:01 +0900710 # NOTE(hichihara): Some neutron vendor plugins were already decomposed and
711 # there is no config file in Neutron tree. They should prepare the file in each plugin.
Martin Hickey30d5fae2015-11-10 13:44:15 +0000712 if [ -f "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" ]; then
713 cp "$NEUTRON_DIR/$Q_PLUGIN_CONF_FILE.sample" /$Q_PLUGIN_CONF_FILE
714 elif [ -f $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE ]; then
Hirofumi Ichihara97cc85b2015-09-08 13:51:01 +0900715 cp $NEUTRON_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
716 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400717
Ihar Hrachyshkab816e5d2014-07-21 13:53:50 +0200718 iniset $NEUTRON_CONF database connection `database_connection_url $Q_DB_NAME`
Mark McClainb05c8762013-07-06 23:29:39 -0400719 iniset $NEUTRON_CONF DEFAULT state_path $DATA_DIR/neutron
salvatoree4e535b2014-10-29 18:22:46 +0100720 iniset $NEUTRON_CONF DEFAULT use_syslog $SYSLOG
Brian Haley180f5eb2015-06-16 13:14:31 -0400721 iniset $NEUTRON_CONF DEFAULT bind_host $Q_LISTEN_ADDRESS
Martin Hickey30d5fae2015-11-10 13:44:15 +0000722 iniset $NEUTRON_CONF oslo_concurrency lock_path $DATA_DIR/neutron/lock
723
Victor Ryzhenkin878d7d82016-04-27 15:15:52 +0300724 # NOTE(freerunner): Need to adjust Region Name for nova in multiregion installation
725 iniset $NEUTRON_CONF nova region_name $REGION_NAME
726
Joe Gordonbee5c502013-08-30 13:48:08 -0400727 if [ "$VIRT_DRIVER" = 'fake' ]; then
728 # Disable arbitrary limits
729 iniset $NEUTRON_CONF quotas quota_network -1
730 iniset $NEUTRON_CONF quotas quota_subnet -1
731 iniset $NEUTRON_CONF quotas quota_port -1
732 iniset $NEUTRON_CONF quotas quota_security_group -1
733 iniset $NEUTRON_CONF quotas quota_security_group_rule -1
734 fi
735
Salvatore Orlando05ae8332013-08-20 14:51:08 -0700736 # Format logging
Sean Dague9751be62016-04-05 12:08:57 -0400737 setup_logging $NEUTRON_CONF
Salvatore Orlando05ae8332013-08-20 14:51:08 -0700738
Rob Crittenden18d47782014-03-19 17:47:42 -0400739 if is_service_enabled tls-proxy; then
740 # Set the service port for a proxy to take the original
741 iniset $NEUTRON_CONF DEFAULT bind_port "$Q_PORT_INT"
742 fi
743
744 if is_ssl_enabled_service "nova"; then
Jamie Lennoxdc757dd2015-03-09 14:48:09 +1100745 iniset $NEUTRON_CONF nova cafile $SSL_BUNDLE_FILE
Rob Crittenden18d47782014-03-19 17:47:42 -0400746 fi
747
748 if is_ssl_enabled_service "neutron"; then
749 ensure_certificates NEUTRON
750
751 iniset $NEUTRON_CONF DEFAULT use_ssl True
752 iniset $NEUTRON_CONF DEFAULT ssl_cert_file "$NEUTRON_SSL_CERT"
753 iniset $NEUTRON_CONF DEFAULT ssl_key_file "$NEUTRON_SSL_KEY"
754 fi
755
Mark McClainb05c8762013-07-06 23:29:39 -0400756 _neutron_setup_rootwrap
757}
758
Ian Wienandaee18c72014-02-21 15:35:08 +1100759function _configure_neutron_dhcp_agent {
Mark McClainb05c8762013-07-06 23:29:39 -0400760
Martin Hickey30d5fae2015-11-10 13:44:15 +0000761 cp $NEUTRON_DIR/etc/dhcp_agent.ini.sample $Q_DHCP_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400762
Ben Nemec03997942013-08-10 09:56:16 -0500763 iniset $Q_DHCP_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Sean Dague78801c12016-08-04 14:10:07 -0400764 # make it so we have working DNS from guests
765 iniset $Q_DHCP_CONF_FILE DEFAULT dnsmasq_local_resolv True
Hirofumi Ichihara2bb3a642015-08-18 12:59:08 -0700766 iniset $Q_DHCP_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
Yuriy Taraday26623952014-07-16 17:41:53 +0400767 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
Hirofumi Ichihara2bb3a642015-08-18 12:59:08 -0700768 iniset $Q_DHCP_CONF_FILE AGENT root_helper_daemon "$Q_RR_DAEMON_COMMAND"
Yuriy Taraday26623952014-07-16 17:41:53 +0400769 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400770
Tan Lin27a196e2014-10-31 15:44:34 +0800771 if ! is_service_enabled q-l3; then
772 if [[ "$ENABLE_ISOLATED_METADATA" = "True" ]]; then
773 iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata $ENABLE_ISOLATED_METADATA
774 iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network $ENABLE_METADATA_NETWORK
775 else
776 if [[ "$ENABLE_METADATA_NETWORK" = "True" ]]; then
777 die "$LINENO" "Enable isolated metadata is a must for metadata network"
778 fi
779 fi
780 fi
781
Mark McClainb05c8762013-07-06 23:29:39 -0400782 _neutron_setup_interface_driver $Q_DHCP_CONF_FILE
783
xurong000379977ef31d02016-07-05 11:09:40 +0800784 neutron_plugin_configure_dhcp_agent $Q_DHCP_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400785}
786
Mark McClainb05c8762013-07-06 23:29:39 -0400787
Ian Wienandaee18c72014-02-21 15:35:08 +1100788function _configure_neutron_metadata_agent {
Martin Hickey30d5fae2015-11-10 13:44:15 +0000789 cp $NEUTRON_DIR/etc/metadata_agent.ini.sample $Q_META_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400790
Ben Nemec03997942013-08-10 09:56:16 -0500791 iniset $Q_META_CONF_FILE DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400792 iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
Armando Migliaccio06f2ea22017-02-02 16:47:00 -0800793 iniset $Q_META_CONF_FILE DEFAULT metadata_workers $API_WORKERS
Hirofumi Ichihara2bb3a642015-08-18 12:59:08 -0700794 iniset $Q_META_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
Yuriy Taraday26623952014-07-16 17:41:53 +0400795 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
Hirofumi Ichihara2bb3a642015-08-18 12:59:08 -0700796 iniset $Q_META_CONF_FILE AGENT root_helper_daemon "$Q_RR_DAEMON_COMMAND"
Yuriy Taraday26623952014-07-16 17:41:53 +0400797 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400798}
799
Dina Belova58adaa62014-07-11 18:18:12 +0400800function _configure_neutron_ceilometer_notifications {
Wanlong Gaocf04a9a2016-01-16 17:46:35 +0800801 iniset $NEUTRON_CONF oslo_messaging_notifications driver messaging
Dina Belova58adaa62014-07-11 18:18:12 +0400802}
803
Ian Wienandaee18c72014-02-21 15:35:08 +1100804function _configure_neutron_metering {
Emilien Macchi40546f72013-09-24 15:10:25 +0200805 neutron_agent_metering_configure_common
806 neutron_agent_metering_configure_agent
807}
808
Brian Haleyeea76212014-06-27 11:45:50 -0400809function _configure_dvr {
810 iniset $NEUTRON_CONF DEFAULT router_distributed True
811 iniset $Q_L3_CONF_FILE DEFAULT agent_mode $Q_DVR_MODE
812}
813
814
Mark McClainb05c8762013-07-06 23:29:39 -0400815# _configure_neutron_plugin_agent() - Set config files for neutron plugin agent
816# It is called when q-agt is enabled.
Ian Wienandaee18c72014-02-21 15:35:08 +1100817function _configure_neutron_plugin_agent {
Mark McClainb05c8762013-07-06 23:29:39 -0400818 # Specify the default root helper prior to agent configuration to
819 # ensure that an agent's configuration can override the default
820 iniset /$Q_PLUGIN_CONF_FILE agent root_helper "$Q_RR_COMMAND"
Yuriy Taraday26623952014-07-16 17:41:53 +0400821 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
822 iniset /$Q_PLUGIN_CONF_FILE agent root_helper_daemon "$Q_RR_DAEMON_COMMAND"
823 fi
Ben Nemec03997942013-08-10 09:56:16 -0500824 iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Mark McClainb05c8762013-07-06 23:29:39 -0400825
826 # Configure agent for plugin
827 neutron_plugin_configure_plugin_agent
828}
829
830# _configure_neutron_service() - Set config files for neutron service
831# It is called when q-svc is enabled.
Ian Wienandaee18c72014-02-21 15:35:08 +1100832function _configure_neutron_service {
Mark McClainb05c8762013-07-06 23:29:39 -0400833 Q_API_PASTE_FILE=$NEUTRON_CONF_DIR/api-paste.ini
Mark McClainb05c8762013-07-06 23:29:39 -0400834 cp $NEUTRON_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
Kevin Benton08a5fcc2014-07-18 16:06:12 -0700835
Mark McClainb05c8762013-07-06 23:29:39 -0400836 # Update either configuration file with plugin
837 iniset $NEUTRON_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
838
839 if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then
840 iniset $NEUTRON_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES
841 fi
842
Ben Nemec03997942013-08-10 09:56:16 -0500843 iniset $NEUTRON_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
Chris Dent74a85b02015-04-22 18:02:39 +0000844 iniset $NEUTRON_CONF oslo_policy policy_file $Q_POLICY_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400845 iniset $NEUTRON_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP
846
847 iniset $NEUTRON_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
848 _neutron_setup_keystone $NEUTRON_CONF keystone_authtoken
849
Atsushi SAKAIfe7b56c2015-11-13 17:06:16 +0900850 # Configuration for neutron notifications to nova.
Terry Wilsonf06c4432014-05-20 10:54:51 -0500851 iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_status_changes $Q_NOTIFY_NOVA_PORT_STATUS_CHANGES
852 iniset $NEUTRON_CONF DEFAULT notify_nova_on_port_data_changes $Q_NOTIFY_NOVA_PORT_DATA_CHANGES
Jamie Lennoxdc757dd2015-03-09 14:48:09 +1100853
Thomas Bechtoldfb948912016-03-27 08:59:42 +0200854 configure_auth_token_middleware $NEUTRON_CONF nova $NEUTRON_AUTH_CACHE_DIR nova
Aaron Rosencea32b12014-03-04 16:20:14 -0800855
Mark McClainb05c8762013-07-06 23:29:39 -0400856 # Configure plugin
857 neutron_plugin_configure_service
858}
859
860# Utility Functions
861#------------------
862
Isaku Yamahata9e136b42013-12-16 15:52:03 +0900863# _neutron_service_plugin_class_add() - add service plugin class
Ian Wienandaee18c72014-02-21 15:35:08 +1100864function _neutron_service_plugin_class_add {
Isaku Yamahata9e136b42013-12-16 15:52:03 +0900865 local service_plugin_class=$1
866 if [[ $Q_SERVICE_PLUGIN_CLASSES == '' ]]; then
867 Q_SERVICE_PLUGIN_CLASSES=$service_plugin_class
868 elif [[ ! ,${Q_SERVICE_PLUGIN_CLASSES}, =~ ,${service_plugin_class}, ]]; then
869 Q_SERVICE_PLUGIN_CLASSES="$Q_SERVICE_PLUGIN_CLASSES,$service_plugin_class"
870 fi
871}
872
YAMAMOTO Takashieede9dd2016-07-15 10:27:53 +0900873# mutnauq_server_config_add() - add server config file
874function mutnauq_server_config_add {
875 _Q_PLUGIN_EXTRA_CONF_FILES_ABS+=($1)
876}
877
Ihar Hrachyshka5893cc72014-12-22 11:49:42 +0100878# _neutron_deploy_rootwrap_filters() - deploy rootwrap filters to $Q_CONF_ROOTWRAP_D (owned by root).
879function _neutron_deploy_rootwrap_filters {
gong yong sheng3d6eaae2015-09-15 15:00:29 +0800880 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
881 return
882 fi
Ihar Hrachyshka5893cc72014-12-22 11:49:42 +0100883 local srcdir=$1
Dean Troyer8421c2b2015-03-16 13:52:19 -0500884 sudo install -d -o root -m 755 $Q_CONF_ROOTWRAP_D
885 sudo install -o root -m 644 $srcdir/etc/neutron/rootwrap.d/* $Q_CONF_ROOTWRAP_D/
Ihar Hrachyshka5893cc72014-12-22 11:49:42 +0100886}
887
Mark McClainb05c8762013-07-06 23:29:39 -0400888# _neutron_setup_rootwrap() - configure Neutron's rootwrap
Ian Wienandaee18c72014-02-21 15:35:08 +1100889function _neutron_setup_rootwrap {
Mark McClainb05c8762013-07-06 23:29:39 -0400890 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
891 return
892 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400893 # Wipe any existing ``rootwrap.d`` files first
894 Q_CONF_ROOTWRAP_D=$NEUTRON_CONF_DIR/rootwrap.d
895 if [[ -d $Q_CONF_ROOTWRAP_D ]]; then
896 sudo rm -rf $Q_CONF_ROOTWRAP_D
897 fi
Ihar Hrachyshka5893cc72014-12-22 11:49:42 +0100898
899 _neutron_deploy_rootwrap_filters $NEUTRON_DIR
900
Mark McClainb05c8762013-07-06 23:29:39 -0400901 # Set up ``rootwrap.conf``, pointing to ``$NEUTRON_CONF_DIR/rootwrap.d``
902 # location moved in newer versions, prefer new location
903 if test -r $NEUTRON_DIR/etc/neutron/rootwrap.conf; then
Dean Troyer8421c2b2015-03-16 13:52:19 -0500904 sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/neutron/rootwrap.conf $Q_RR_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400905 else
Dean Troyer8421c2b2015-03-16 13:52:19 -0500906 sudo install -o root -g root -m 644 $NEUTRON_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE
Mark McClainb05c8762013-07-06 23:29:39 -0400907 fi
908 sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE
Robert Li2c5d4622015-04-21 15:48:22 -0400909 sudo sed -e 's:^exec_dirs=\(.*\)$:exec_dirs=\1,/usr/local/bin:' -i $Q_RR_CONF_FILE
910
Mark McClainb05c8762013-07-06 23:29:39 -0400911 # Specify ``rootwrap.conf`` as first parameter to neutron-rootwrap
912 ROOTWRAP_SUDOER_CMD="$NEUTRON_ROOTWRAP $Q_RR_CONF_FILE *"
Yuriy Taraday26623952014-07-16 17:41:53 +0400913 ROOTWRAP_DAEMON_SUDOER_CMD="$NEUTRON_ROOTWRAP-daemon $Q_RR_CONF_FILE"
Mark McClainb05c8762013-07-06 23:29:39 -0400914
915 # Set up the rootwrap sudoers for neutron
916 TEMPFILE=`mktemp`
Stephan Renatuse578eff2013-11-19 13:31:04 +0100917 echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
Yuriy Taraday26623952014-07-16 17:41:53 +0400918 echo "$STACK_USER ALL=(root) NOPASSWD: $ROOTWRAP_DAEMON_SUDOER_CMD" >>$TEMPFILE
Mark McClainb05c8762013-07-06 23:29:39 -0400919 chmod 0440 $TEMPFILE
920 sudo chown root:root $TEMPFILE
921 sudo mv $TEMPFILE /etc/sudoers.d/neutron-rootwrap
922
923 # Update the root_helper
924 iniset $NEUTRON_CONF agent root_helper "$Q_RR_COMMAND"
Yuriy Taraday26623952014-07-16 17:41:53 +0400925 if [[ "$Q_USE_ROOTWRAP_DAEMON" == "True" ]]; then
926 iniset $NEUTRON_CONF agent root_helper_daemon "$Q_RR_DAEMON_COMMAND"
927 fi
Mark McClainb05c8762013-07-06 23:29:39 -0400928}
929
Ihar Hrachyshkabb4654b2015-10-06 18:09:07 +0200930# Configures keystone integration for neutron service
Ian Wienandaee18c72014-02-21 15:35:08 +1100931function _neutron_setup_keystone {
Mark McClainb05c8762013-07-06 23:29:39 -0400932 local conf_file=$1
933 local section=$2
Jamie Lennox3561d7f2014-05-21 17:18:43 +1000934
Brant Knudson05952372014-09-19 17:22:22 -0500935 create_neutron_cache_dir
936 configure_auth_token_middleware $conf_file $Q_ADMIN_USERNAME $NEUTRON_AUTH_CACHE_DIR $section
Mark McClainb05c8762013-07-06 23:29:39 -0400937}
938
Ian Wienandaee18c72014-02-21 15:35:08 +1100939function _neutron_setup_interface_driver {
Mark McClainb05c8762013-07-06 23:29:39 -0400940
941 # ovs_use_veth needs to be set before the plugin configuration
942 # occurs to allow plugins to override the setting.
943 iniset $1 DEFAULT ovs_use_veth $Q_OVS_USE_VETH
944
945 neutron_plugin_setup_interface_driver $1
946}
Mark McClainb05c8762013-07-06 23:29:39 -0400947# Functions for Neutron Exercises
948#--------------------------------
949
Ian Wienandaee18c72014-02-21 15:35:08 +1100950function delete_probe {
Mark McClainb05c8762013-07-06 23:29:39 -0400951 local from_net="$1"
952 net_id=`_get_net_id $from_net`
953 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}'`
954 neutron-debug --os-tenant-name admin --os-username admin probe-delete $probe_id
955}
956
Ian Wienandaee18c72014-02-21 15:35:08 +1100957function _get_net_id {
Victor Ryzhenkin878d7d82016-04-27 15:15:52 +0300958 neutron --os-cloud devstack-admin --os-region "$REGION_NAME" --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}'
Mark McClainb05c8762013-07-06 23:29:39 -0400959}
960
Ian Wienandaee18c72014-02-21 15:35:08 +1100961function _get_probe_cmd_prefix {
Mark McClainb05c8762013-07-06 23:29:39 -0400962 local from_net="$1"
963 net_id=`_get_net_id $from_net`
964 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`
965 echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id"
966}
967
Mark McClainb05c8762013-07-06 23:29:39 -0400968# ssh check
Ian Wienandaee18c72014-02-21 15:35:08 +1100969function _ssh_check_neutron {
Mark McClainb05c8762013-07-06 23:29:39 -0400970 local from_net=$1
971 local key_file=$2
972 local ip=$3
973 local user=$4
974 local timeout_sec=$5
975 local probe_cmd = ""
976 probe_cmd=`_get_probe_cmd_prefix $from_net`
Sean Dague442e4e92015-06-24 13:24:02 -0400977 local testcmd="$probe_cmd ssh -o StrictHostKeyChecking=no -i $key_file ${user}@$ip echo success"
978 test_with_retry "$testcmd" "server $ip didn't become ssh-able" $timeout_sec
Mark McClainb05c8762013-07-06 23:29:39 -0400979}
980
Mark McClainb05c8762013-07-06 23:29:39 -0400981# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100982$_XTRACE_NEUTRON
Mark McClainb05c8762013-07-06 23:29:39 -0400983
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100984# Tell emacs to use shell-script-mode
985## Local variables:
986## mode: shell-script
987## End: