blob: 96ccf206c9e080804fe78bc130264856006457f4 [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
Salvatore Orlandod6767d02012-08-31 04:55:20 -070056# Save trace setting
57XTRACE=$(set +o | grep xtrace)
58set +o xtrace
59
Dean Troyer60e9c0a2012-12-06 15:52:52 -060060
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090061# Quantum Network Configuration
62# -----------------------------
Dean Troyer60e9c0a2012-12-06 15:52:52 -060063
64# Set up default directories
Nachi Ueno8bc21f62012-11-19 22:04:28 -080065QUANTUM_DIR=$DEST/quantum
Dean Troyer60e9c0a2012-12-06 15:52:52 -060066QUANTUMCLIENT_DIR=$DEST/python-quantumclient
Gary Kotton9343df12012-11-28 10:05:53 +000067QUANTUM_AUTH_CACHE_DIR=${QUANTUM_AUTH_CACHE_DIR:-/var/cache/quantum}
Nachi Ueno5db5bfa2012-10-29 11:25:29 -070068
Dean Troyer60e9c0a2012-12-06 15:52:52 -060069QUANTUM_CONF_DIR=/etc/quantum
70QUANTUM_CONF=$QUANTUM_CONF_DIR/quantum.conf
71export QUANTUM_TEST_CONFIG_FILE=${QUANTUM_TEST_CONFIG_FILE:-"$QUANTUM_CONF_DIR/debug.ini"}
72
73# Default Quantum Plugin
74Q_PLUGIN=${Q_PLUGIN:-openvswitch}
75# Default Quantum Port
76Q_PORT=${Q_PORT:-9696}
77# Default Quantum Host
78Q_HOST=${Q_HOST:-$HOST_IP}
Dean Troyer60e9c0a2012-12-06 15:52:52 -060079# Default admin username
80Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum}
81# Default auth strategy
82Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
83# Use namespace or not
84Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
85Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
86# Meta data IP
87Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090088# Allow Overlapping IP among subnets
Salvatore Orlandod1742fe2013-03-07 13:34:57 +010089Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-True}
Dean Troyer60e9c0a2012-12-06 15:52:52 -060090# Use quantum-debug command
91Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
Maru Newby31c94ab2012-12-19 03:59:20 +000092# The name of the default q-l3 router
93Q_ROUTER_NAME=${Q_ROUTER_NAME:-router1}
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -070094# List of config file names in addition to the main plugin config file
95# See _configure_quantum_common() for details about setting it up
96declare -a Q_PLUGIN_EXTRA_CONF_FILES
Dean Troyer60e9c0a2012-12-06 15:52:52 -060097
Nachi Ueno8bc21f62012-11-19 22:04:28 -080098if is_service_enabled quantum; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -060099 Q_RR_CONF_FILE=$QUANTUM_CONF_DIR/rootwrap.conf
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800100 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
101 Q_RR_COMMAND="sudo"
102 else
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800103 QUANTUM_ROOTWRAP=$(get_rootwrap_location quantum)
104 Q_RR_COMMAND="sudo $QUANTUM_ROOTWRAP $Q_RR_CONF_FILE"
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800105 fi
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800106
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900107 # Provider Network Configurations
108 # --------------------------------
109
110 # The following variables control the Quantum openvswitch and
111 # linuxbridge plugins' allocation of tenant networks and
112 # availability of provider networks. If these are not configured
113 # in localrc, tenant networks will be local to the host (with no
114 # remote connectivity), and no physical resources will be
115 # available for the allocation of provider networks.
116
117 # To use GRE tunnels for tenant networks, set to True in
118 # localrc. GRE tunnels are only supported by the openvswitch
119 # plugin, and currently only on Ubuntu.
120 ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-False}
121
122 # If using GRE tunnels for tenant networks, specify the range of
123 # tunnel IDs from which tenant networks are allocated. Can be
124 # overriden in localrc in necesssary.
125 TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGE:-1:1000}
126
127 # To use VLANs for tenant networks, set to True in localrc. VLANs
128 # are supported by the openvswitch and linuxbridge plugins, each
129 # requiring additional configuration described below.
130 ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False}
131
132 # If using VLANs for tenant networks, set in localrc to specify
133 # the range of VLAN VIDs from which tenant networks are
134 # allocated. An external network switch must be configured to
135 # trunk these VLANs between hosts for multi-host connectivity.
136 #
137 # Example: ``TENANT_VLAN_RANGE=1000:1999``
138 TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-}
139
140 # If using VLANs for tenant networks, or if using flat or VLAN
141 # provider networks, set in localrc to the name of the physical
142 # network, and also configure OVS_PHYSICAL_BRIDGE for the
143 # openvswitch agent or LB_PHYSICAL_INTERFACE for the linuxbridge
144 # agent, as described below.
145 #
146 # Example: ``PHYSICAL_NETWORK=default``
147 PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-}
148
149 # With the openvswitch plugin, if using VLANs for tenant networks,
150 # or if using flat or VLAN provider networks, set in localrc to
151 # the name of the OVS bridge to use for the physical network. The
152 # bridge will be created if it does not already exist, but a
153 # physical interface must be manually added to the bridge as a
154 # port for external connectivity.
155 #
156 # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1``
157 OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-}
158
159 # With the linuxbridge plugin, if using VLANs for tenant networks,
160 # or if using flat or VLAN provider networks, set in localrc to
161 # the name of the network interface to use for the physical
162 # network.
163 #
164 # Example: ``LB_PHYSICAL_INTERFACE=eth1``
165 LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-}
166
167 # With the openvswitch plugin, set to True in localrc to enable
168 # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False.
169 #
170 # Example: ``OVS_ENABLE_TUNNELING=True``
171 OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
172fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600173
Dean Troyercc6b4432013-04-08 15:38:03 -0500174
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 Troyercc6b4432013-04-08 15:38:03 -0500192
193# Functions
194# ---------
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600195
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900196# configure_quantum()
197# Set common config for all quantum server and agents.
198function configure_quantum() {
199 _configure_quantum_common
Akihiro MOTOKIb0f1c382013-01-13 17:58:12 +0900200 iniset_rpc_backend quantum $QUANTUM_CONF DEFAULT
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900201
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400202 # goes before q-svc to init Q_SERVICE_PLUGIN_CLASSES
203 if is_service_enabled q-lbaas; then
204 _configure_quantum_lbaas
205 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900206 if is_service_enabled q-svc; then
207 _configure_quantum_service
208 fi
209 if is_service_enabled q-agt; then
210 _configure_quantum_plugin_agent
211 fi
212 if is_service_enabled q-dhcp; then
213 _configure_quantum_dhcp_agent
214 fi
215 if is_service_enabled q-l3; then
216 _configure_quantum_l3_agent
217 fi
218 if is_service_enabled q-meta; then
219 _configure_quantum_metadata_agent
220 fi
221
222 _configure_quantum_debug_command
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900223}
224
225function create_nova_conf_quantum() {
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800226 iniset $NOVA_CONF DEFAULT network_api_class "nova.network.quantumv2.api.API"
227 iniset $NOVA_CONF DEFAULT quantum_admin_username "$Q_ADMIN_USERNAME"
228 iniset $NOVA_CONF DEFAULT quantum_admin_password "$SERVICE_PASSWORD"
229 iniset $NOVA_CONF DEFAULT quantum_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
230 iniset $NOVA_CONF DEFAULT quantum_auth_strategy "$Q_AUTH_STRATEGY"
231 iniset $NOVA_CONF DEFAULT quantum_admin_tenant_name "$SERVICE_TENANT_NAME"
232 iniset $NOVA_CONF DEFAULT quantum_url "http://$Q_HOST:$Q_PORT"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900233
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900234 if [[ "$Q_USE_SECGROUP" == "True" ]]; then
235 LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
236 iniset $NOVA_CONF DEFAULT security_group_api quantum
237 fi
238
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900239 # set NOVA_VIF_DRIVER and optionally set options in nova_conf
240 quantum_plugin_create_nova_conf
241
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800242 iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER"
243 iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900244 if is_service_enabled q-meta; then
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800245 iniset $NOVA_CONF DEFAULT service_quantum_metadata_proxy "True"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900246 fi
247}
248
249# create_quantum_accounts() - Set up common required quantum accounts
250
251# Tenant User Roles
252# ------------------------------------------------------------------
253# service quantum admin # if enabled
254
255# Migrated from keystone_data.sh
256function create_quantum_accounts() {
257
258 SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
259 ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
260
261 if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
262 QUANTUM_USER=$(keystone user-create \
263 --name=quantum \
264 --pass="$SERVICE_PASSWORD" \
265 --tenant_id $SERVICE_TENANT \
266 --email=quantum@example.com \
267 | grep " id " | get_field 2)
268 keystone user-role-add \
269 --tenant_id $SERVICE_TENANT \
270 --user_id $QUANTUM_USER \
271 --role_id $ADMIN_ROLE
272 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
273 QUANTUM_SERVICE=$(keystone service-create \
274 --name=quantum \
275 --type=network \
276 --description="Quantum Service" \
277 | grep " id " | get_field 2)
278 keystone endpoint-create \
279 --region RegionOne \
280 --service_id $QUANTUM_SERVICE \
281 --publicurl "http://$SERVICE_HOST:9696/" \
282 --adminurl "http://$SERVICE_HOST:9696/" \
283 --internalurl "http://$SERVICE_HOST:9696/"
284 fi
285 fi
286}
287
288function create_quantum_initial_network() {
289 TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
290
291 # Create a small network
292 # Since quantum command is executed in admin context at this point,
293 # ``--tenant_id`` needs to be specified.
Devananda van der Veen37a8d152013-01-15 17:27:34 -0800294 if is_baremetal; then
295 sudo ovs-vsctl add-port $OVS_PHYSICAL_BRIDGE $PUBLIC_INTERFACE
296 for IP in $(ip addr show dev $PUBLIC_INTERFACE | grep ' inet ' | awk '{print $2}'); do
297 sudo ip addr del $IP dev $PUBLIC_INTERFACE
298 sudo ip addr add $IP dev $OVS_PHYSICAL_BRIDGE
299 done
300 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)
301 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)
302 sudo ifconfig $OVS_PHYSICAL_BRIDGE up
303 else
304 NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
305 SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
306 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900307
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800308 if [[ "$Q_L3_ENABLED" == "True" ]]; then
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900309 # Create a router, and add the private subnet as one of its interfaces
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800310 if [[ "$Q_L3_ROUTER_PER_TENANT" == "True" ]]; then
311 # create a tenant-owned router.
Maru Newby31c94ab2012-12-19 03:59:20 +0000312 ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID $Q_ROUTER_NAME | grep ' id ' | get_field 2)
313 else
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800314 # Plugin only supports creating a single router, which should be admin owned.
Maru Newby31c94ab2012-12-19 03:59:20 +0000315 ROUTER_ID=$(quantum router-create $Q_ROUTER_NAME | grep ' id ' | get_field 2)
316 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900317 quantum router-interface-add $ROUTER_ID $SUBNET_ID
318 # Create an external network, and a subnet. Configure the external network as router gw
319 EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
Stephen Ma8396d4f2013-02-18 05:32:59 -0800320 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 +0900321 quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
322
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800323 if is_service_enabled q-l3; then
324 # logic is specific to using the l3-agent for l3
325 if is_quantum_ovs_base_plugin && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
326 CIDR_LEN=${FLOATING_RANGE#*/}
327 sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
328 sudo ip link set $PUBLIC_BRIDGE up
329 ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
330 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
331 fi
332 if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
333 # Explicitly set router id in l3 agent configuration
334 iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
335 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900336 fi
337 fi
338}
339
340# init_quantum() - Initialize databases, etc.
341function init_quantum() {
342 :
343}
344
345# install_quantum() - Collect source and prepare
346function install_quantum() {
347 git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH
Dean Troyerfe51a902013-04-01 15:48:44 -0500348 setup_develop $QUANTUM_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900349}
350
351# install_quantumclient() - Collect source and prepare
352function install_quantumclient() {
353 git_clone $QUANTUMCLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUMCLIENT_BRANCH
Dean Troyerfe51a902013-04-01 15:48:44 -0500354 setup_develop $QUANTUMCLIENT_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900355}
356
357# install_quantum_agent_packages() - Collect source and prepare
358function install_quantum_agent_packages() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900359 # install packages that is specific to plugin agent
360 quantum_plugin_install_agent_packages
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900361}
362
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900363# Start running processes, including screen
364function start_quantum_service_and_check() {
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700365 # build config-file options
366 local cfg_file
367 local CFG_FILE_OPTIONS="--config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
368 for cfg_file in ${Q_PLUGIN_EXTRA_CONF_FILES[@]}; do
369 CFG_FILE_OPTIONS+=" --config-file /$cfg_file"
370 done
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900371 # Start the Quantum service
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700372 screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server $CFG_FILE_OPTIONS"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900373 echo "Waiting for Quantum to start..."
Aaron Rosen0ae742c2013-02-21 12:10:30 -0800374 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 -0800375 die $LINENO "Quantum did not start"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900376 fi
377}
378
379# Start running processes, including screen
380function start_quantum_agents() {
381 # Start up the quantum agents if enabled
Dean Troyer58ab9292013-03-19 15:39:47 -0500382 screen_it q-agt "cd $QUANTUM_DIR && python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
383 screen_it q-dhcp "cd $QUANTUM_DIR && python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE"
384 screen_it q-l3 "cd $QUANTUM_DIR && python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
385 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 +0400386
387 if is_service_enabled q-lbaas; then
Dean Troyer58ab9292013-03-19 15:39:47 -0500388 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 +0400389 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900390}
391
392# stop_quantum() - Stop running processes (non-screen)
393function stop_quantum() {
394 if is_service_enabled q-dhcp; then
395 pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }')
396 [ ! -z "$pid" ] && sudo kill -9 $pid
397 fi
398}
399
Dean Troyer995eb922013-03-07 16:11:40 -0600400# cleanup_quantum() - Remove residual data files, anything left over from previous
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900401# runs that a clean run would need to clean up
Dean Troyer995eb922013-03-07 16:11:40 -0600402function cleanup_quantum() {
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900403 :
404}
405
406# _configure_quantum_common()
407# Set common config for all quantum server and agents.
408# This MUST be called before other _configure_quantum_* functions.
409function _configure_quantum_common() {
410 # Put config files in ``QUANTUM_CONF_DIR`` for everyone to find
411 if [[ ! -d $QUANTUM_CONF_DIR ]]; then
412 sudo mkdir -p $QUANTUM_CONF_DIR
413 fi
Attila Fazekas91b8d132013-01-06 22:40:09 +0100414 sudo chown $STACK_USER $QUANTUM_CONF_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900415
416 cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF
417
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700418 # Set plugin-specific variables Q_DB_NAME, Q_PLUGIN_CLASS.
419 # For main plugin config file, set Q_PLUGIN_CONF_PATH, Q_PLUGIN_CONF_FILENAME.
420 # For addition plugin config files, set Q_PLUGIN_EXTRA_CONF_PATH,
421 # Q_PLUGIN_EXTRA_CONF_FILES. For example:
422 # Q_PLUGIN_EXTRA_CONF_FILES=(file1, file2)
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900423 quantum_plugin_configure_common
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900424
425 if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -0800426 die $LINENO "Quantum plugin not set.. exiting"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900427 fi
428
429 # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR``
430 mkdir -p /$Q_PLUGIN_CONF_PATH
431 Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
432 cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
433
Attila Fazekas7e79d912013-03-03 12:23:04 +0100434 iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection `database_connection_url $Q_DB_NAME`
mathieu-rohoncf9c10d2013-03-18 17:34:03 +0100435 iniset $QUANTUM_CONF DEFAULT state_path $DATA_DIR/quantum
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900436
Baodong (Robert) Li7a8d8522013-03-21 06:16:55 -0700437 # If addition config files are set, make sure their path name is set as well
438 if [[ ${#Q_PLUGIN_EXTRA_CONF_FILES[@]} > 0 && $Q_PLUGIN_EXTRA_CONF_PATH == '' ]]; then
439 die $LINENO "Quantum additional plugin config not set.. exiting"
440 fi
441
442 # If additional config files exist, copy them over to quantum configuration
443 # directory
444 if [[ $Q_PLUGIN_EXTRA_CONF_PATH != '' ]]; then
445 mkdir -p /$Q_PLUGIN_EXTRA_CONF_PATH
446 local f
447 for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do
448 Q_PLUGIN_EXTRA_CONF_FILES[$f]=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
449 cp $QUANTUM_DIR/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} /${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
450 done
451 fi
452
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900453 _quantum_setup_rootwrap
454}
455
456function _configure_quantum_debug_command() {
457 if [[ "$Q_USE_DEBUG_COMMAND" != "True" ]]; then
458 return
459 fi
460
461 cp $QUANTUM_DIR/etc/l3_agent.ini $QUANTUM_TEST_CONFIG_FILE
462
463 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT verbose False
464 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT debug False
465 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
466 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND"
Gary Kottond9ca2b22013-01-30 13:52:43 +0000467 # Intermediate fix until Quantum patch lands and then line above will
468 # be cleaned.
469 iniset $QUANTUM_TEST_CONFIG_FILE AGENT root_helper "$Q_RR_COMMAND"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900470
471 _quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url
472 _quantum_setup_interface_driver $QUANTUM_TEST_CONFIG_FILE
473
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900474 quantum_plugin_configure_debug_command
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900475}
476
477function _configure_quantum_dhcp_agent() {
478 AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent"
479 Q_DHCP_CONF_FILE=$QUANTUM_CONF_DIR/dhcp_agent.ini
480
481 cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE
482
483 iniset $Q_DHCP_CONF_FILE DEFAULT verbose True
484 iniset $Q_DHCP_CONF_FILE DEFAULT debug True
485 iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900486 iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
487
488 _quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url
489 _quantum_setup_interface_driver $Q_DHCP_CONF_FILE
490
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900491 quantum_plugin_configure_dhcp_agent
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900492}
493
494function _configure_quantum_l3_agent() {
Dan Wendlandt555ecd02013-02-23 23:07:07 -0800495 Q_L3_ENABLED=True
496 # for l3-agent, only use per tenant router if we have namespaces
497 Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900498 AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
499 PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
500 Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini
501
502 cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
503
504 iniset $Q_L3_CONF_FILE DEFAULT verbose True
505 iniset $Q_L3_CONF_FILE DEFAULT debug True
506 iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900507 iniset $Q_L3_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
508
509 _quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url
510 _quantum_setup_interface_driver $Q_L3_CONF_FILE
511
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900512 quantum_plugin_configure_l3_agent
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900513}
514
515function _configure_quantum_metadata_agent() {
516 AGENT_META_BINARY="$QUANTUM_DIR/bin/quantum-metadata-agent"
517 Q_META_CONF_FILE=$QUANTUM_CONF_DIR/metadata_agent.ini
518
519 cp $QUANTUM_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE
520
521 iniset $Q_META_CONF_FILE DEFAULT verbose True
522 iniset $Q_META_CONF_FILE DEFAULT debug True
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900523 iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
524 iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
525
526 _quantum_setup_keystone $Q_META_CONF_FILE DEFAULT set_auth_url
527}
528
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400529function _configure_quantum_lbaas()
530{
531 quantum_agent_lbaas_install_agent_packages
532 quantum_agent_lbaas_configure_common
533 quantum_agent_lbaas_configure_agent
534}
535
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900536# _configure_quantum_plugin_agent() - Set config files for quantum plugin agent
537# It is called when q-agt is enabled.
538function _configure_quantum_plugin_agent() {
Maru Newby2298ca42012-10-25 23:46:42 +0000539 # Specify the default root helper prior to agent configuration to
Gary Kotton98e18e92013-01-28 14:26:56 +0000540 # ensure that an agent's configuration can override the default
Maru Newby2298ca42012-10-25 23:46:42 +0000541 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
mathieu-rohon3ebb01a2013-04-09 15:09:07 +0200542 iniset $QUANTUM_CONF DEFAULT verbose True
543 iniset $QUANTUM_CONF DEFAULT debug True
Maru Newby2298ca42012-10-25 23:46:42 +0000544
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900545 # Configure agent for plugin
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900546 quantum_plugin_configure_plugin_agent
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900547}
548
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900549# _configure_quantum_service() - Set config files for quantum service
550# It is called when q-svc is enabled.
551function _configure_quantum_service() {
552 Q_API_PASTE_FILE=$QUANTUM_CONF_DIR/api-paste.ini
553 Q_POLICY_FILE=$QUANTUM_CONF_DIR/policy.json
554
555 cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
556 cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
557
558 if is_service_enabled $DATABASE_BACKENDS; then
559 recreate_database $Q_DB_NAME utf8
560 else
Nachi Ueno07115eb2013-02-26 12:38:18 -0800561 die $LINENO "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin."
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900562 fi
563
564 # Update either configuration file with plugin
565 iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
566
Eugene Nikanorovb7d82842013-03-06 16:28:33 +0400567 if [[ $Q_SERVICE_PLUGIN_CLASSES != '' ]]; then
568 iniset $QUANTUM_CONF DEFAULT service_plugins $Q_SERVICE_PLUGIN_CLASSES
569 fi
570
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900571 iniset $QUANTUM_CONF DEFAULT verbose True
572 iniset $QUANTUM_CONF DEFAULT debug True
Salvatore Orlando3de02e82013-03-12 15:12:12 +0100573 iniset $QUANTUM_CONF DEFAULT policy_file $Q_POLICY_FILE
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900574 iniset $QUANTUM_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP
575
576 iniset $QUANTUM_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
Akihiro MOTOKI712feb62013-02-11 23:45:19 +0900577 _quantum_setup_keystone $QUANTUM_CONF keystone_authtoken
578 # Comment out keystone authtoken configuration in api-paste.ini
579 # It is required to avoid any breakage in Quantum where the sample
580 # api-paste.ini has authtoken configurations.
581 _quantum_commentout_keystone_authtoken $Q_API_PASTE_FILE filter:authtoken
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900582
583 # Configure plugin
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900584 quantum_plugin_configure_service
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900585}
586
587# Utility Functions
588#------------------
589
590# _quantum_setup_rootwrap() - configure Quantum's rootwrap
591function _quantum_setup_rootwrap() {
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800592 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
593 return
594 fi
595 # Deploy new rootwrap filters files (owned by root).
596 # Wipe any existing rootwrap.d files first
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600597 Q_CONF_ROOTWRAP_D=$QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800598 if [[ -d $Q_CONF_ROOTWRAP_D ]]; then
599 sudo rm -rf $Q_CONF_ROOTWRAP_D
600 fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600601 # Deploy filters to $QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800602 mkdir -p -m 755 $Q_CONF_ROOTWRAP_D
603 cp -pr $QUANTUM_DIR/etc/quantum/rootwrap.d/* $Q_CONF_ROOTWRAP_D/
604 sudo chown -R root:root $Q_CONF_ROOTWRAP_D
605 sudo chmod 644 $Q_CONF_ROOTWRAP_D/*
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600606 # Set up rootwrap.conf, pointing to $QUANTUM_CONF_DIR/rootwrap.d
Dirk Mueller13aab252013-03-18 18:55:09 +0100607 # location moved in newer versions, prefer new location
608 if test -r $QUANTUM_DIR/etc/quantum/rootwrap.conf; then
609 sudo cp -p $QUANTUM_DIR/etc/quantum/rootwrap.conf $Q_RR_CONF_FILE
610 else
611 sudo cp -p $QUANTUM_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE
612 fi
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800613 sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE
614 sudo chown root:root $Q_RR_CONF_FILE
615 sudo chmod 0644 $Q_RR_CONF_FILE
616 # Specify rootwrap.conf as first parameter to quantum-rootwrap
617 ROOTWRAP_SUDOER_CMD="$QUANTUM_ROOTWRAP $Q_RR_CONF_FILE *"
618
619 # Set up the rootwrap sudoers for quantum
620 TEMPFILE=`mktemp`
621 echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
622 chmod 0440 $TEMPFILE
623 sudo chown root:root $TEMPFILE
624 sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap
Gary Kotton98e18e92013-01-28 14:26:56 +0000625
626 # Update the root_helper
627 iniset $QUANTUM_CONF AGENT root_helper "$Q_RR_COMMAND"
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800628}
629
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700630# Configures keystone integration for quantum service and agents
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900631function _quantum_setup_keystone() {
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700632 local conf_file=$1
633 local section=$2
634 local use_auth_url=$3
635 if [[ -n $use_auth_url ]]; then
636 iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0"
637 else
638 iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST
639 iniset $conf_file $section auth_port $KEYSTONE_AUTH_PORT
640 iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL
641 fi
642 iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME
643 iniset $conf_file $section admin_user $Q_ADMIN_USERNAME
644 iniset $conf_file $section admin_password $SERVICE_PASSWORD
Akihiro MOTOKI5e3deb62012-12-11 17:09:02 +0900645 iniset $conf_file $section signing_dir $QUANTUM_AUTH_CACHE_DIR
646 # Create cache dir
647 sudo mkdir -p $QUANTUM_AUTH_CACHE_DIR
Attila Fazekas91b8d132013-01-06 22:40:09 +0100648 sudo chown $STACK_USER $QUANTUM_AUTH_CACHE_DIR
Vishvananda Ishaya23431f32012-12-12 15:57:33 -0800649 rm -f $QUANTUM_AUTH_CACHE_DIR/*
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700650}
651
Akihiro MOTOKI712feb62013-02-11 23:45:19 +0900652function _quantum_commentout_keystone_authtoken() {
653 local conf_file=$1
654 local section=$2
655
656 inicomment $conf_file $section auth_host
657 inicomment $conf_file $section auth_port
658 inicomment $conf_file $section auth_protocol
659 inicomment $conf_file $section auth_url
660
661 inicomment $conf_file $section admin_tenant_name
662 inicomment $conf_file $section admin_user
663 inicomment $conf_file $section admin_password
664 inicomment $conf_file $section signing_dir
665}
666
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900667function _quantum_setup_interface_driver() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900668 quantum_plugin_setup_interface_driver $1
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000669}
670
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900671# Functions for Quantum Exercises
672#--------------------------------
673
674function delete_probe() {
675 local from_net="$1"
676 net_id=`_get_net_id $from_net`
677 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}'`
678 quantum-debug --os-tenant-name admin --os-username admin probe-delete $probe_id
679}
680
681function setup_quantum_debug() {
682 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
683 public_net_id=`_get_net_id $PUBLIC_NETWORK_NAME`
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900684 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 +0900685 private_net_id=`_get_net_id $PRIVATE_NETWORK_NAME`
Akihiro MOTOKI3452f8e2013-03-21 14:11:27 +0900686 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 +0000687 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900688}
689
690function teardown_quantum_debug() {
691 delete_probe $PUBLIC_NETWORK_NAME
692 delete_probe $PRIVATE_NETWORK_NAME
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000693}
694
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700695function _get_net_id() {
696 quantum --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}'
697}
698
699function _get_probe_cmd_prefix() {
700 local from_net="$1"
701 net_id=`_get_net_id $from_net`
702 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 -0800703 echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700704}
705
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700706function _ping_check_quantum() {
707 local from_net=$1
708 local ip=$2
709 local timeout_sec=$3
710 local expected=${4:-"True"}
711 local check_command=""
712 probe_cmd=`_get_probe_cmd_prefix $from_net`
713 if [[ "$expected" = "True" ]]; then
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800714 check_command="while ! $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700715 else
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800716 check_command="while $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700717 fi
718 if ! timeout $timeout_sec sh -c "$check_command"; then
719 if [[ "$expected" = "True" ]]; then
Nachi Ueno07115eb2013-02-26 12:38:18 -0800720 die $LINENO "[Fail] Couldn't ping server"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700721 else
Nachi Ueno07115eb2013-02-26 12:38:18 -0800722 die $LINENO "[Fail] Could ping server"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700723 fi
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700724 fi
725}
726
727# ssh check
728function _ssh_check_quantum() {
729 local from_net=$1
730 local key_file=$2
731 local ip=$3
732 local user=$4
733 local timeout_sec=$5
734 local probe_cmd = ""
735 probe_cmd=`_get_probe_cmd_prefix $from_net`
Dean Troyercc6b4432013-04-08 15:38:03 -0500736 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 -0800737 die $LINENO "server didn't become ssh-able!"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700738 fi
739}
740
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900741# Quantum 3rd party programs
742#---------------------------
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900743# please refer to lib/quantum_thirdparty/README.md for details
744QUANTUM_THIRD_PARTIES=""
745for f in $TOP_DIR/lib/quantum_thirdparty/*; do
746 third_party=$(basename $f)
747 if is_service_enabled $third_party; then
748 source $TOP_DIR/lib/quantum_thirdparty/$third_party
749 QUANTUM_THIRD_PARTIES="$QUANTUM_THIRD_PARTIES,$third_party"
750 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900751done
752
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900753function _quantum_third_party_do() {
754 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
755 ${1}_${third_party}
756 done
757}
758
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900759# configure_quantum_third_party() - Set config files, create data dirs, etc
760function configure_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900761 _quantum_third_party_do configure
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700762}
763
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900764# init_quantum_third_party() - Initialize databases, etc.
765function init_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900766 _quantum_third_party_do init
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700767}
768
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900769# install_quantum_third_party() - Collect source and prepare
770function install_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900771 _quantum_third_party_do install
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900772}
773
774# start_quantum_third_party() - Start running processes, including screen
775function start_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900776 _quantum_third_party_do start
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900777}
778
779# stop_quantum_third_party - Stop running processes (non-screen)
780function stop_quantum_third_party() {
Isaku Yamahata0dd34df2012-12-28 13:15:31 +0900781 _quantum_third_party_do stop
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900782}
783
784
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700785# Restore xtrace
786$XTRACE
Sean Dague584d90e2013-03-29 14:34:53 -0400787
788# Local variables:
789# mode: shell-script
790# End: