blob: e2a0d5349fcee91c51348687014853b025ac4c6c [file] [log] [blame]
Salvatore Orlandod6767d02012-08-31 04:55:20 -07001# lib/quantum
2# functions - funstions specific to quantum
3
Dean Troyer60e9c0a2012-12-06 15:52:52 -06004# Dependencies:
5# ``functions`` file
6# ``DEST`` must be defined
7
Akihiro MOTOKI66afb472012-12-21 15:34:13 +09008# ``stack.sh`` calls the entry points in this order:
9#
10# install_quantum
11# install_quantumclient
12# install_quantum_agent_packages
13# install_quantum_third_party
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090014# configure_quantum
15# init_quantum
16# configure_quantum_third_party
17# init_quantum_third_party
18# start_quantum_third_party
19# create_nova_conf_quantum
20# start_quantum_service_and_check
21# create_quantum_initial_network
22# setup_quantum_debug
23# start_quantum_agents
24#
25# ``unstack.sh`` calls the entry points in this order:
26#
27# stop_quantum
28
29# Functions in lib/quantum are classified into the following categories:
30#
31# - entry points (called from stack.sh or unstack.sh)
32# - internal functions
33# - quantum exercises
34# - 3rd party programs
35
Dean Troyer60e9c0a2012-12-06 15:52:52 -060036
37# Quantum Networking
38# ------------------
39
40# Make sure that quantum is enabled in ``ENABLED_SERVICES``. If you want
41# to run Quantum on this host, make sure that q-svc is also in
42# ``ENABLED_SERVICES``.
43#
44# If you're planning to use the Quantum 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 Quantum
47# linuxbridge plugin, set ``Q_PLUGIN`` to "linuxbridge" and make sure the
48# q-agt service is enabled in ``ENABLED_SERVICES``.
49#
50# See "Quantum Network Configuration" below for additional variables
51# that must be set in localrc for connectivity across hosts with
52# Quantum.
53#
Dean Troyerb3236912013-03-17 15:17:05 -050054# With Quantum networking the NETWORK_MANAGER variable is ignored.
Dean Troyer60e9c0a2012-12-06 15:52:52 -060055
56
Salvatore Orlandod6767d02012-08-31 04:55:20 -070057# Save trace setting
58XTRACE=$(set +o | grep xtrace)
59set +o xtrace
60
Dean Troyer60e9c0a2012-12-06 15:52:52 -060061
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090062# Quantum Network Configuration
63# -----------------------------
Dean Troyer60e9c0a2012-12-06 15:52:52 -060064
65# Set up default directories
Nachi Ueno8bc21f62012-11-19 22:04:28 -080066QUANTUM_DIR=$DEST/quantum
Dean Troyer60e9c0a2012-12-06 15:52:52 -060067QUANTUMCLIENT_DIR=$DEST/python-quantumclient
Gary Kotton9343df12012-11-28 10:05:53 +000068QUANTUM_AUTH_CACHE_DIR=${QUANTUM_AUTH_CACHE_DIR:-/var/cache/quantum}
Nachi Ueno5db5bfa2012-10-29 11:25:29 -070069
Dean Troyer60e9c0a2012-12-06 15:52:52 -060070QUANTUM_CONF_DIR=/etc/quantum
71QUANTUM_CONF=$QUANTUM_CONF_DIR/quantum.conf
72export QUANTUM_TEST_CONFIG_FILE=${QUANTUM_TEST_CONFIG_FILE:-"$QUANTUM_CONF_DIR/debug.ini"}
73
74# Default Quantum Plugin
75Q_PLUGIN=${Q_PLUGIN:-openvswitch}
76# Default Quantum Port
77Q_PORT=${Q_PORT:-9696}
78# Default Quantum Host
79Q_HOST=${Q_HOST:-$HOST_IP}
Dean Troyer60e9c0a2012-12-06 15:52:52 -060080# Default admin username
81Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum}
82# Default auth strategy
83Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
84# Use namespace or not
85Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
86Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
87# Meta data IP
88Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090089# Allow Overlapping IP among subnets
Salvatore Orlandod1742fe2013-03-07 13:34:57 +010090Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True}
Dean Troyer60e9c0a2012-12-06 15:52:52 -060091# Use quantum-debug command
92Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
Maru Newby31c94ab2012-12-19 03:59:20 +000093# The name of the default q-l3 router
94Q_ROUTER_NAME=${Q_ROUTER_NAME:-router1}
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -070095# List of config file names in addition to the main plugin config file
96# See _configure_quantum_common() for details about setting it up
97declare -a Q_PLUGIN_EXTRA_CONF_FILES
Dean Troyer60e9c0a2012-12-06 15:52:52 -060098
Nachi Ueno8bc21f62012-11-19 22:04:28 -080099if is_service_enabled quantum; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600100 Q_RR_CONF_FILE=$QUANTUM_CONF_DIR/rootwrap.conf
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800101 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
102 Q_RR_COMMAND="sudo"
103 else
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800104 QUANTUM_ROOTWRAP=$(get_rootwrap_location quantum)
105 Q_RR_COMMAND="sudo $QUANTUM_ROOTWRAP $Q_RR_CONF_FILE"
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800106 fi
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800107
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900108 # Provider Network Configurations
109 # --------------------------------
110
111 # The following variables control the Quantum openvswitch and
112 # linuxbridge plugins' allocation of tenant networks and
113 # availability of provider networks. If these are not configured
114 # in localrc, tenant networks will be local to the host (with no
115 # remote connectivity), and no physical resources will be
116 # available for the allocation of provider networks.
117
118 # To use GRE tunnels for tenant networks, set to True in
119 # localrc. GRE tunnels are only supported by the openvswitch
120 # plugin, and currently only on Ubuntu.
121 ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-False}
122
123 # If using GRE tunnels for tenant networks, specify the range of
124 # tunnel IDs from which tenant networks are allocated. Can be
125 # overriden in localrc in necesssary.
126 TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGE:-1:1000}
127
128 # To use VLANs for tenant networks, set to True in localrc. VLANs
129 # are supported by the openvswitch and linuxbridge plugins, each
130 # requiring additional configuration described below.
131 ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False}
132
133 # If using VLANs for tenant networks, set in localrc to specify
134 # the range of VLAN VIDs from which tenant networks are
135 # allocated. An external network switch must be configured to
136 # trunk these VLANs between hosts for multi-host connectivity.
137 #
138 # Example: ``TENANT_VLAN_RANGE=1000:1999``
139 TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-}
140
141 # If using VLANs for tenant networks, or if using flat or VLAN
142 # provider networks, set in localrc to the name of the physical
143 # network, and also configure OVS_PHYSICAL_BRIDGE for the
144 # openvswitch agent or LB_PHYSICAL_INTERFACE for the linuxbridge
145 # agent, as described below.
146 #
147 # Example: ``PHYSICAL_NETWORK=default``
148 PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-}
149
150 # With the openvswitch plugin, if using VLANs for tenant networks,
151 # or if using flat or VLAN provider networks, set in localrc to
152 # the name of the OVS bridge to use for the physical network. The
153 # bridge will be created if it does not already exist, but a
154 # physical interface must be manually added to the bridge as a
155 # port for external connectivity.
156 #
157 # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1``
158 OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-}
159
160 # With the linuxbridge plugin, if using VLANs for tenant networks,
161 # or if using flat or VLAN provider networks, set in localrc to
162 # the name of the network interface to use for the physical
163 # network.
164 #
165 # Example: ``LB_PHYSICAL_INTERFACE=eth1``
166 LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-}
167
168 # With the openvswitch plugin, set to True in localrc to enable
169 # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False.
170 #
171 # Example: ``OVS_ENABLE_TUNNELING=True``
172 OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
173fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600174
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900175# Quantum plugin specific functions
176# ---------------------------------
177# Please refer to lib/quantum_plugins/README.md for details.
178source $TOP_DIR/lib/quantum_plugins/$Q_PLUGIN
179
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400180# Agent loadbalancer service plugin functions
181# -------------------------------------------
182# Hardcoding for 1 service plugin for now
Akihiro MOTOKIc07112a2013-03-22 16:35:38 +0900183source $TOP_DIR/lib/quantum_plugins/services/agent_loadbalancer
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400184
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900185# Use security group or not
186if has_quantum_plugin_security_group; then
187 Q_USE_SECGROUP=${Q_USE_SECGROUP:-True}
188else
189 Q_USE_SECGROUP=False
190fi
191
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600192# Entry Points
193# ------------
194
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900195# configure_quantum()
196# Set common config for all quantum server and agents.
197function configure_quantum() {
198 _configure_quantum_common
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900199 iniset_rpc_backend quantum $QUANTUM_CONF DEFAULT
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900200
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400201 # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES
202 if is_service_enabled q-lbaas; then
203 _configure_quantum_lbaas
204 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900205 if is_service_enabled q-svc; then
206 _configure_quantum_service
207 fi
208 if is_service_enabled q-agt; then
209 _configure_quantum_plugin_agent
210 fi
211 if is_service_enabled q-dhcp; then
212 _configure_quantum_dhcp_agent
213 fi
214 if is_service_enabled q-l3; then
215 _configure_quantum_l3_agent
216 fi
217 if is_service_enabled q-meta; then
218 _configure_quantum_metadata_agent
219 fi
220
221 _configure_quantum_debug_command
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900222}
223
224function create_nova_conf_quantum() {
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800225 iniset $NOVA_CONF DEFAULT network_api_class "nova.network.quantumv2.api.API"
226 iniset $NOVA_CONF DEFAULT quantum_admin_username "$Q_ADMIN_USERNAME"
227 iniset $NOVA_CONF DEFAULT quantum_admin_password "$SERVICE_PASSWORD"
228 iniset $NOVA_CONF DEFAULT quantum_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
229 iniset $NOVA_CONF DEFAULT quantum_auth_strategy "$Q_AUTH_STRATEGY"
230 iniset $NOVA_CONF DEFAULT quantum_admin_tenant_name "$SERVICE_TENANT_NAME"
231 iniset $NOVA_CONF DEFAULT quantum_url "http://$Q_HOST:$Q_PORT"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900232
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900233 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
234 LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
235 iniset $NOVA_CONF DEFAULT security_group_api quantum
236 fi
237
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900238 # set NOVA_VIF_DRIVER and optionally set options in nova_conf
239 quantum_plugin_create_nova_conf
240
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800241 iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER"
242 iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900243 if is_service_enabled q-meta; then
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800244 iniset $NOVA_CONF DEFAULT service_quantum_metadata_proxy "True"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900245 fi
246}
247
248# create_quantum_accounts() - Set up common required quantum accounts
249
250# Tenant User Roles
251# ------------------------------------------------------------------
252# service quantum admin # if enabled
253
254# Migrated from keystone_data.sh
255function create_quantum_accounts() {
256
257 SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
258 ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
259
260 if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
261 QUANTUM_USER=$(keystone user-create \
262 --name=quantum \
263 --pass="$SERVICE_PASSWORD" \
264 --tenant_id $SERVICE_TENANT \
265 --email=quantum@example.com \
266 | grep " id " | get_field 2)
267 keystone user-role-add \
268 --tenant_id $SERVICE_TENANT \
269 --user_id $QUANTUM_USER \
270 --role_id $ADMIN_ROLE
271 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
272 QUANTUM_SERVICE=$(keystone service-create \
273 --name=quantum \
274 --type=network \
275 --description="Quantum Service" \
276 | grep " id " | get_field 2)
277 keystone endpoint-create \
278 --region RegionOne \
279 --service_id $QUANTUM_SERVICE \
280 --publicurl "http://$SERVICE_HOST:9696/" \
281 --adminurl "http://$SERVICE_HOST:9696/" \
282 --internalurl "http://$SERVICE_HOST:9696/"
283 fi
284 fi
285}
286
287function create_quantum_initial_network() {
288 TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
289
290 # Create a small network
291 # Since quantum command is executed in admin context at this point,
292 # ``--tenant_id`` needs to be specified.
Devananda van der Veen37a8d152013-01-15 17:27:34 -0800293 if is_baremetal; then
294 sudo ovs-vsctl add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE
295 for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do
296 sudo ip addr del $IP dev $PUBLIC_INTERFACE
297 sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
298 done
299 NET_ID=$(quantum net-create $PHYSICAL_NETWORK --tenant_id $TENANT_ID --provider:network_type flat --provider:physical_network "$PHYSICAL_NETWORK" | grep ' id ' | get_field 2)
300 SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 ${ALLOCATION_POOL:+--allocation-pool $ALLOCATION_POOL} --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
301 sudo ifconfig $OVS_PHYSICAL_BRIDGE up
302 else
303 NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
304 SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
305 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900306
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800307 if [[ "$Q_L3_ENABLED" == "True" ]]; then
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900308 # Create a router, and add the private subnet as one of its interfaces
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800309 if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
310 # create a tenant-owned router.
Maru Newby31c94ab2012-12-19 03:59:20 +0000311 ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2)
312 else
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800313 # Plugin only supports creating a single router, which should be admin owned.
Maru Newby31c94ab2012-12-19 03:59:20 +0000314 ROUTER_ID=$(quantum router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
315 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900316 quantum router-interface-add $ROUTER_ID $SUBNET_ID
317 # Create an external network, and a subnet. Configure the external network as router gw
318 EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
Stephen Ma8396d4f2013-02-18 05:32:59 -0800319 EXT_GW_IP=$(quantum subnet-create --ip_version 4 ${Q_FLOATING_ALLOCATION_POOL:+--allocation-pool $Q_FLOATING_ALLOCATION_POOL} $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900320 quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
321
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800322 if is_service_enabled q-l3; then
323 # logic is specific to using the l3-agent for l3
324 if is_quantum_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
325 CIDR_LEN=${FLOATING_RANGE#*/}
326 sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
327 sudo ip link set $PUBLIC_BRIDGE up
328 ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
329 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
330 fi
331 if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
332 # Explicitly set router id in l3 agent configuration
333 iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
334 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900335 fi
336 fi
337}
338
339# init_quantum() - Initialize databases, etc.
340function init_quantum() {
341 :
342}
343
344# install_quantum() - Collect source and prepare
345function install_quantum() {
346 git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH
Dean Troyerfe51a902013-04-01 15:48:44 -0500347 setup_develop $QUANTUM_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900348}
349
350# install_quantumclient() - Collect source and prepare
351function install_quantumclient() {
352 git_clone $QUANTUMCLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUMCLIENT_BRANCH
Dean Troyerfe51a902013-04-01 15:48:44 -0500353 setup_develop $QUANTUMCLIENT_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900354}
355
356# install_quantum_agent_packages() - Collect source and prepare
357function install_quantum_agent_packages() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900358 # install packages that is specific to plugin agent
359 quantum_plugin_install_agent_packages
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900360}
361
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900362# Start running processes, including screen
363function start_quantum_service_and_check() {
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700364 # build config-file options
365 local cfg_file
366 local CFG_FILE_OPTIONS="--config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
367 for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do
368 CFG_FILE_OPTIONS+=" --config-file /$cfg_file"
369 done
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900370 # Start the Quantum service
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700371 screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server $CFG_FILE_OPTIONS"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900372 echo "Waiting for Quantum to start..."
Aaron Rosen0ae742c2013-02-21 12:10:30 -0800373 if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://$Q_HOST:$Q_PORT; do sleep 1; done"; then
Nachi Ueno07115eb2013-02-26 12:38:18 -0800374 die $LINENO "Quantum did not start"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900375 fi
376}
377
378# Start running processes, including screen
379function start_quantum_agents() {
380 # Start up the quantum agents if enabled
Dean Troyer58ab9292013-03-19 15:39:47 -0500381 screen_it q-agt "cd $QUANTUM_DIR && python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
382 screen_it q-dhcp "cd $QUANTUM_DIR && python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE"
383 screen_it q-l3 "cd $QUANTUM_DIR && python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
384 screen_it q-meta "cd $QUANTUM_DIR && python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE"
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400385
386 if is_service_enabled q-lbaas; then
Dean Troyer58ab9292013-03-19 15:39:47 -0500387 screen_it q-lbaas "cd $QUANTUM_DIR && python $AGENT_LBAAS_BINARY --config-file $QUANTUM_CONF --config-file=$LBAAS_AGENT_CONF_FILENAME"
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400388 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900389}
390
391# stop_quantum() - Stop running processes (non-screen)
392function stop_quantum() {
393 if is_service_enabled q-dhcp; then
394 pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }')
395 [ ! -z "$pid" ] && sudo kill -9 $pid
396 fi
397}
398
Dean Troyer995eb922013-03-07 16:11:40 -0600399# cleanup_quantum() - Remove residual data files, anything left over from previous
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900400# runs that a clean run would need to clean up
Dean Troyer995eb922013-03-07 16:11:40 -0600401function cleanup_quantum() {
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900402 :
403}
404
405# _configure_quantum_common()
406# Set common config for all quantum server and agents.
407# This MUST be called before other _configure_quantum_* functions.
408function _configure_quantum_common() {
409 # Put config files in ``QUANTUM_CONF_DIR`` for everyone to find
410 if [[ ! -d $QUANTUM_CONF_DIR ]]; then
411 sudo mkdir -p $QUANTUM_CONF_DIR
412 fi
Attila Fazekas91b8d132013-01-06 22:40:09 +0100413 sudo chown $STACK_USER $QUANTUM_CONF_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900414
415 cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF
416
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700417 # Set plugin-specific variables Q_DB_NAME, Q_PLUGIN_CLASS.
418 # For main plugin config file, set Q_PLUGIN_CONF_PATH, Q_PLUGIN_CONF_FILENAME.
419 # For addition plugin config files, set Q_PLUGIN_EXTRA_CONF_PATH,
420 # Q_PLUGIN_EXTRA_CONF_FILES. For example:
421 # Q_PLUGIN_EXTRA_CONF_FILES=(file1, file2)
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900422 quantum_plugin_configure_common
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900423
424 if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -0800425 die $LINENO "Quantum plugin not set.. exiting"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900426 fi
427
428 # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR``
429 mkdir -p /$Q_PLUGIN_CONF_PATH
430 Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
431 cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
432
Attila Fazekas7e79d912013-03-03 12:23:04 +0100433 iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection `database_connection_url $Q_DB_NAME`
mathieu-rohoncf9c10d2013-03-18 17:34:03 +0100434 iniset $QUANTUM_CONF DEFAULT state_path $DATA_DIR/quantum
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900435
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700436 # If addition config files are set, make sure their path name is set as well
437 if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 && $Q_PLUGIN_EXTRA_CONF_PATH == '' ]]; then
438 die $LINENO "Quantum additional plugin config not set.. exiting"
439 fi
440
441 # If additional config files exist, copy them over to quantum configuration
442 # directory
443 if [[ $Q_PLUGIN_EXTRA_CONF_PATH != '' ]]; then
444 mkdir -p /$Q_PLUGIN_EXTRA_CONF_PATH
445 local f
446 for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do
447 Q_PLUGIN_EXTRA_CONF_FILES[$f]=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
448 cp $QUANTUM_DIR/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} /${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
449 done
450 fi
451
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900452 _quantum_setup_rootwrap
453}
454
455function _configure_quantum_debug_command() {
456 if [[ "$Q_USE_DEBUG_COMMAND" != "True" ]]; then
457 return
458 fi
459
460 cp $QUANTUM_DIR/etc/l3_agent.ini $QUANTUM_TEST_CONFIG_FILE
461
462 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT verbose False
463 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT debug False
464 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
465 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND"
Gary Kottond9ca2b22013-01-30 13:52:43 +0000466 # Intermediate fix until Quantum patch lands and then line above will
467 # be cleaned.
468 iniset $QUANTUM_TEST_CONFIG_FILE AGENT root_helper "$Q_RR_COMMAND"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900469
470 _quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url
471 _quantum_setup_interface_driver $QUANTUM_TEST_CONFIG_FILE
472
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900473 quantum_plugin_configure_debug_command
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900474}
475
476function _configure_quantum_dhcp_agent() {
477 AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent"
478 Q_DHCP_CONF_FILE=$QUANTUM_CONF_DIR/dhcp_agent.ini
479
480 cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE
481
482 iniset $Q_DHCP_CONF_FILE DEFAULT verbose True
483 iniset $Q_DHCP_CONF_FILE DEFAULT debug True
484 iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900485 iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
486
487 _quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url
488 _quantum_setup_interface_driver $Q_DHCP_CONF_FILE
489
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900490 quantum_plugin_configure_dhcp_agent
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900491}
492
493function _configure_quantum_l3_agent() {
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800494 Q_L3_ENABLED=True
495 # for l3-agent, only use per tenant router if we have namespaces
496 Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900497 AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
498 PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
499 Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini
500
501 cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
502
503 iniset $Q_L3_CONF_FILE DEFAULT verbose True
504 iniset $Q_L3_CONF_FILE DEFAULT debug True
505 iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900506 iniset $Q_L3_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
507
508 _quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url
509 _quantum_setup_interface_driver $Q_L3_CONF_FILE
510
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900511 quantum_plugin_configure_l3_agent
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900512}
513
514function _configure_quantum_metadata_agent() {
515 AGENT_META_BINARY="$QUANTUM_DIR/bin/quantum-metadata-agent"
516 Q_META_CONF_FILE=$QUANTUM_CONF_DIR/metadata_agent.ini
517
518 cp $QUANTUM_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE
519
520 iniset $Q_META_CONF_FILE DEFAULT verbose True
521 iniset $Q_META_CONF_FILE DEFAULT debug True
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900522 iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
523 iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
524
525 _quantum_setup_keystone $Q_META_CONF_FILE DEFAULT set_auth_url
526}
527
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400528function _configure_quantum_lbaas()
529{
530 quantum_agent_lbaas_install_agent_packages
531 quantum_agent_lbaas_configure_common
532 quantum_agent_lbaas_configure_agent
533}
534
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900535# _configure_quantum_plugin_agent() - Set config files for quantum plugin agent
536# It is called when q-agt is enabled.
537function _configure_quantum_plugin_agent() {
Maru Newby2298ca42012-10-25 23:46:42 +0000538 # Specify the default root helper prior to agent configuration to
Gary Kotton98e18e92013-01-28 14:26:56 +0000539 # ensure that an agent's configuration can override the default
Maru Newby2298ca42012-10-25 23:46:42 +0000540 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
541
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900542 # Configure agent for plugin
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900543 quantum_plugin_configure_plugin_agent
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900544}
545
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900546# _configure_quantum_service() - Set config files for quantum service
547# It is called when q-svc is enabled.
548function _configure_quantum_service() {
549 Q_API_PASTE_FILE=$QUANTUM_CONF_DIR/api-paste.ini
550 Q_POLICY_FILE=$QUANTUM_CONF_DIR/policy.json
551
552 cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
553 cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
554
555 if is_service_enabled $DATABASE_BACKENDS; then
556 recreate_database $Q_DB_NAME utf8
557 else
Nachi Ueno07115eb2013-02-26 12:38:18 -0800558 die $LINENO "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin."
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900559 fi
560
561 # Update either configuration file with plugin
562 iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
563
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400564 if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then
565 iniset $QUANTUM_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES
566 fi
567
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900568 iniset $QUANTUM_CONF DEFAULT verbose True
569 iniset $QUANTUM_CONF DEFAULT debug True
Salvatore Orlando3de02e82013-03-12 15:12:12 +0100570 iniset $QUANTUM_CONF DEFAULT policy_file $Q_POLICY_FILE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900571 iniset $QUANTUM_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP
572
573 iniset $QUANTUM_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
Akihiro MOTOKI712feb62013-02-11 23:45:19 +0900574 _quantum_setup_keystone $QUANTUM_CONF keystone_authtoken
575 # Comment out keystone authtoken configuration in api-paste.ini
576 # It is required to avoid any breakage in Quantum where the sample
577 # api-paste.ini has authtoken configurations.
578 _quantum_commentout_keystone_authtoken $Q_API_PASTE_FILE filter:authtoken
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900579
580 # Configure plugin
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900581 quantum_plugin_configure_service
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900582}
583
584# Utility Functions
585#------------------
586
587# _quantum_setup_rootwrap() - configure Quantum's rootwrap
588function _quantum_setup_rootwrap() {
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800589 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
590 return
591 fi
592 # Deploy new rootwrap filters files (owned by root).
593 # Wipe any existing rootwrap.d files first
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600594 Q_CONF_ROOTWRAP_D=$QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800595 if [[ -d $Q_CONF_ROOTWRAP_D ]]; then
596 sudo rm -rf $Q_CONF_ROOTWRAP_D
597 fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600598 # Deploy filters to $QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800599 mkdir -p -m 755 $Q_CONF_ROOTWRAP_D
600 cp -pr $QUANTUM_DIR/etc/quantum/rootwrap.d/* $Q_CONF_ROOTWRAP_D/
601 sudo chown -R root:root $Q_CONF_ROOTWRAP_D
602 sudo chmod 644 $Q_CONF_ROOTWRAP_D/*
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600603 # Set up rootwrap.conf, pointing to $QUANTUM_CONF_DIR/rootwrap.d
Dirk Mueller13aab252013-03-18 18:55:09 +0100604 # location moved in newer versions, prefer new location
605 if test -r $QUANTUM_DIR/etc/quantum/rootwrap.conf; then
606 sudo cp -p $QUANTUM_DIR/etc/quantum/rootwrap.conf $Q_RR_CONF_FILE
607 else
608 sudo cp -p $QUANTUM_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE
609 fi
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800610 sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE
611 sudo chown root:root $Q_RR_CONF_FILE
612 sudo chmod 0644 $Q_RR_CONF_FILE
613 # Specify rootwrap.conf as first parameter to quantum-rootwrap
614 ROOTWRAP_SUDOER_CMD="$QUANTUM_ROOTWRAP $Q_RR_CONF_FILE *"
615
616 # Set up the rootwrap sudoers for quantum
617 TEMPFILE=`mktemp`
618 echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
619 chmod 0440 $TEMPFILE
620 sudo chown root:root $TEMPFILE
621 sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap
Gary Kotton98e18e92013-01-28 14:26:56 +0000622
623 # Update the root_helper
624 iniset $QUANTUM_CONF AGENT root_helper "$Q_RR_COMMAND"
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800625}
626
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700627# Configures keystone integration for quantum service and agents
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900628function _quantum_setup_keystone() {
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700629 local conf_file=$1
630 local section=$2
631 local use_auth_url=$3
632 if [[ -n $use_auth_url ]]; then
633 iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0"
634 else
635 iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST
636 iniset $conf_file $section auth_port $KEYSTONE_AUTH_PORT
637 iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL
638 fi
639 iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME
640 iniset $conf_file $section admin_user $Q_ADMIN_USERNAME
641 iniset $conf_file $section admin_password $SERVICE_PASSWORD
Akihiro MOTOKI5e3deb62012-12-11 17:09:02 +0900642 iniset $conf_file $section signing_dir $QUANTUM_AUTH_CACHE_DIR
643 # Create cache dir
644 sudo mkdir -p $QUANTUM_AUTH_CACHE_DIR
Attila Fazekas91b8d132013-01-06 22:40:09 +0100645 sudo chown $STACK_USER $QUANTUM_AUTH_CACHE_DIR
Vishvananda Ishaya23431f32012-12-12 15:57:33 -0800646 rm -f $QUANTUM_AUTH_CACHE_DIR/*
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700647}
648
Akihiro MOTOKI712feb62013-02-11 23:45:19 +0900649function _quantum_commentout_keystone_authtoken() {
650 local conf_file=$1
651 local section=$2
652
653 inicomment $conf_file $section auth_host
654 inicomment $conf_file $section auth_port
655 inicomment $conf_file $section auth_protocol
656 inicomment $conf_file $section auth_url
657
658 inicomment $conf_file $section admin_tenant_name
659 inicomment $conf_file $section admin_user
660 inicomment $conf_file $section admin_password
661 inicomment $conf_file $section signing_dir
662}
663
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900664function _quantum_setup_interface_driver() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900665 quantum_plugin_setup_interface_driver $1
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000666}
667
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900668# Functions for Quantum Exercises
669#--------------------------------
670
671function delete_probe() {
672 local from_net="$1"
673 net_id=`_get_net_id $from_net`
674 probe_id=`quantum-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}'`
675 quantum-debug --os-tenant-name admin --os-username admin probe-delete $probe_id
676}
677
678function setup_quantum_debug() {
679 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
680 public_net_id=`_get_net_id $PUBLIC_NETWORK_NAME`
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900681 quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $public_net_id
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900682 private_net_id=`_get_net_id $PRIVATE_NETWORK_NAME`
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900683 quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create --device-owner compute $private_net_id
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000684 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900685}
686
687function teardown_quantum_debug() {
688 delete_probe $PUBLIC_NETWORK_NAME
689 delete_probe $PRIVATE_NETWORK_NAME
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000690}
691
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700692function _get_net_id() {
693 quantum --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}'
694}
695
696function _get_probe_cmd_prefix() {
697 local from_net="$1"
698 net_id=`_get_net_id $from_net`
699 probe_id=`quantum-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`
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800700 echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700701}
702
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700703function _ping_check_quantum() {
704 local from_net=$1
705 local ip=$2
706 local timeout_sec=$3
707 local expected=${4:-"True"}
708 local check_command=""
709 probe_cmd=`_get_probe_cmd_prefix $from_net`
710 if [[ "$expected" = "True" ]]; then
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800711 check_command="while ! $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700712 else
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800713 check_command="while $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700714 fi
715 if ! timeout $timeout_sec sh -c "$check_command"; then
716 if [[ "$expected" = "True" ]]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -0800717 die $LINENO "[Fail] Couldn't ping server"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700718 else
Nachi Ueno07115eb2013-02-26 12:38:18 -0800719 die $LINENO "[Fail] Could ping server"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700720 fi
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700721 fi
722}
723
724# ssh check
725function _ssh_check_quantum() {
726 local from_net=$1
727 local key_file=$2
728 local ip=$3
729 local user=$4
730 local timeout_sec=$5
731 local probe_cmd = ""
732 probe_cmd=`_get_probe_cmd_prefix $from_net`
733 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
Nachi Ueno07115eb2013-02-26 12:38:18 -0800734 die $LINENO "server didn't become ssh-able!"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700735 fi
736}
737
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900738# Quantum 3rd party programs
739#---------------------------
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900740# please refer to lib/quantum_thirdparty/README.md for details
741QUANTUM_THIRD_PARTIES=""
742for f in $TOP_DIR/lib/quantum_thirdparty/*; do
743 third_party=$(basename $f)
744 if is_service_enabled $third_party; then
745 source $TOP_DIR/lib/quantum_thirdparty/$third_party
746 QUANTUM_THIRD_PARTIES="$QUANTUM_THIRD_PARTIES,$third_party"
747 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900748done
749
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900750function _quantum_third_party_do() {
751 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
752 ${1}_${third_party}
753 done
754}
755
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900756# configure_quantum_third_party() - Set config files, create data dirs, etc
757function configure_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900758 _quantum_third_party_do configure
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700759}
760
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900761# init_quantum_third_party() - Initialize databases, etc.
762function init_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900763 _quantum_third_party_do init
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700764}
765
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900766# install_quantum_third_party() - Collect source and prepare
767function install_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900768 _quantum_third_party_do install
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900769}
770
771# start_quantum_third_party() - Start running processes, including screen
772function start_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900773 _quantum_third_party_do start
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900774}
775
776# stop_quantum_third_party - Stop running processes (non-screen)
777function stop_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900778 _quantum_third_party_do stop
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900779}
780
781
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700782# Restore xtrace
783$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400784
785# Local variables:
786# mode: shell-script
787# End: