blob: 343e5a9b0c9b8d8ef5b00fb704fbbc7cbfe8c8b9 [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
14# setup_quantum
15# setup_quantumclient
16# configure_quantum
17# init_quantum
18# configure_quantum_third_party
19# init_quantum_third_party
20# start_quantum_third_party
21# create_nova_conf_quantum
22# start_quantum_service_and_check
23# create_quantum_initial_network
24# setup_quantum_debug
25# start_quantum_agents
26#
27# ``unstack.sh`` calls the entry points in this order:
28#
29# stop_quantum
30
31# Functions in lib/quantum are classified into the following categories:
32#
33# - entry points (called from stack.sh or unstack.sh)
34# - internal functions
35# - quantum exercises
36# - 3rd party programs
37
Dean Troyer60e9c0a2012-12-06 15:52:52 -060038
39# Quantum Networking
40# ------------------
41
42# Make sure that quantum is enabled in ``ENABLED_SERVICES``. If you want
43# to run Quantum on this host, make sure that q-svc is also in
44# ``ENABLED_SERVICES``.
45#
46# If you're planning to use the Quantum openvswitch plugin, set
47# ``Q_PLUGIN`` to "openvswitch" and make sure the q-agt service is enabled
48# in ``ENABLED_SERVICES``. If you're planning to use the Quantum
49# linuxbridge plugin, set ``Q_PLUGIN`` to "linuxbridge" and make sure the
50# q-agt service is enabled in ``ENABLED_SERVICES``.
51#
52# See "Quantum Network Configuration" below for additional variables
53# that must be set in localrc for connectivity across hosts with
54# Quantum.
55#
56# With Quantum networking the NET_MAN variable is ignored.
57
58
Salvatore Orlandod6767d02012-08-31 04:55:20 -070059# Save trace setting
60XTRACE=$(set +o | grep xtrace)
61set +o xtrace
62
Dean Troyer60e9c0a2012-12-06 15:52:52 -060063
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090064# Quantum Network Configuration
65# -----------------------------
Dean Troyer60e9c0a2012-12-06 15:52:52 -060066
67# Set up default directories
Nachi Ueno8bc21f62012-11-19 22:04:28 -080068QUANTUM_DIR=$DEST/quantum
Dean Troyer60e9c0a2012-12-06 15:52:52 -060069QUANTUMCLIENT_DIR=$DEST/python-quantumclient
Gary Kotton9343df12012-11-28 10:05:53 +000070QUANTUM_AUTH_CACHE_DIR=${QUANTUM_AUTH_CACHE_DIR:-/var/cache/quantum}
Nachi Ueno5db5bfa2012-10-29 11:25:29 -070071
Dean Troyer60e9c0a2012-12-06 15:52:52 -060072QUANTUM_CONF_DIR=/etc/quantum
73QUANTUM_CONF=$QUANTUM_CONF_DIR/quantum.conf
74export QUANTUM_TEST_CONFIG_FILE=${QUANTUM_TEST_CONFIG_FILE:-"$QUANTUM_CONF_DIR/debug.ini"}
75
76# Default Quantum Plugin
77Q_PLUGIN=${Q_PLUGIN:-openvswitch}
78# Default Quantum Port
79Q_PORT=${Q_PORT:-9696}
80# Default Quantum Host
81Q_HOST=${Q_HOST:-$HOST_IP}
Dean Troyer60e9c0a2012-12-06 15:52:52 -060082# Default admin username
83Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum}
84# Default auth strategy
85Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
86# Use namespace or not
87Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
88Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
89# Meta data IP
90Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +090091# Allow Overlapping IP among subnets
92Q_ALLOW_OVERLAPPING_IP=${Q_ALLOW_OVERLAPPING_IP:-False}
Dean Troyer60e9c0a2012-12-06 15:52:52 -060093# Use quantum-debug command
94Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
95
Nachi Ueno8bc21f62012-11-19 22:04:28 -080096if is_service_enabled quantum; then
Dean Troyer60e9c0a2012-12-06 15:52:52 -060097 Q_RR_CONF_FILE=$QUANTUM_CONF_DIR/rootwrap.conf
Nachi Ueno8bc21f62012-11-19 22:04:28 -080098 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
99 Q_RR_COMMAND="sudo"
100 else
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800101 QUANTUM_ROOTWRAP=$(get_rootwrap_location quantum)
102 Q_RR_COMMAND="sudo $QUANTUM_ROOTWRAP $Q_RR_CONF_FILE"
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800103 fi
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800104
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900105 # Provider Network Configurations
106 # --------------------------------
107
108 # The following variables control the Quantum openvswitch and
109 # linuxbridge plugins' allocation of tenant networks and
110 # availability of provider networks. If these are not configured
111 # in localrc, tenant networks will be local to the host (with no
112 # remote connectivity), and no physical resources will be
113 # available for the allocation of provider networks.
114
115 # To use GRE tunnels for tenant networks, set to True in
116 # localrc. GRE tunnels are only supported by the openvswitch
117 # plugin, and currently only on Ubuntu.
118 ENABLE_TENANT_TUNNELS=${ENABLE_TENANT_TUNNELS:-False}
119
120 # If using GRE tunnels for tenant networks, specify the range of
121 # tunnel IDs from which tenant networks are allocated. Can be
122 # overriden in localrc in necesssary.
123 TENANT_TUNNEL_RANGES=${TENANT_TUNNEL_RANGE:-1:1000}
124
125 # To use VLANs for tenant networks, set to True in localrc. VLANs
126 # are supported by the openvswitch and linuxbridge plugins, each
127 # requiring additional configuration described below.
128 ENABLE_TENANT_VLANS=${ENABLE_TENANT_VLANS:-False}
129
130 # If using VLANs for tenant networks, set in localrc to specify
131 # the range of VLAN VIDs from which tenant networks are
132 # allocated. An external network switch must be configured to
133 # trunk these VLANs between hosts for multi-host connectivity.
134 #
135 # Example: ``TENANT_VLAN_RANGE=1000:1999``
136 TENANT_VLAN_RANGE=${TENANT_VLAN_RANGE:-}
137
138 # If using VLANs for tenant networks, or if using flat or VLAN
139 # provider networks, set in localrc to the name of the physical
140 # network, and also configure OVS_PHYSICAL_BRIDGE for the
141 # openvswitch agent or LB_PHYSICAL_INTERFACE for the linuxbridge
142 # agent, as described below.
143 #
144 # Example: ``PHYSICAL_NETWORK=default``
145 PHYSICAL_NETWORK=${PHYSICAL_NETWORK:-}
146
147 # With the openvswitch plugin, if using VLANs for tenant networks,
148 # or if using flat or VLAN provider networks, set in localrc to
149 # the name of the OVS bridge to use for the physical network. The
150 # bridge will be created if it does not already exist, but a
151 # physical interface must be manually added to the bridge as a
152 # port for external connectivity.
153 #
154 # Example: ``OVS_PHYSICAL_BRIDGE=br-eth1``
155 OVS_PHYSICAL_BRIDGE=${OVS_PHYSICAL_BRIDGE:-}
156
157 # With the linuxbridge plugin, if using VLANs for tenant networks,
158 # or if using flat or VLAN provider networks, set in localrc to
159 # the name of the network interface to use for the physical
160 # network.
161 #
162 # Example: ``LB_PHYSICAL_INTERFACE=eth1``
163 LB_PHYSICAL_INTERFACE=${LB_PHYSICAL_INTERFACE:-}
164
165 # With the openvswitch plugin, set to True in localrc to enable
166 # provider GRE tunnels when ``ENABLE_TENANT_TUNNELS`` is False.
167 #
168 # Example: ``OVS_ENABLE_TUNNELING=True``
169 OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
170fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600171
172# Entry Points
173# ------------
174
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900175# configure_quantum()
176# Set common config for all quantum server and agents.
177function configure_quantum() {
178 _configure_quantum_common
179 _configure_quantum_rpc
180
181 if is_service_enabled q-svc; then
182 _configure_quantum_service
183 fi
184 if is_service_enabled q-agt; then
185 _configure_quantum_plugin_agent
186 fi
187 if is_service_enabled q-dhcp; then
188 _configure_quantum_dhcp_agent
189 fi
190 if is_service_enabled q-l3; then
191 _configure_quantum_l3_agent
192 fi
193 if is_service_enabled q-meta; then
194 _configure_quantum_metadata_agent
195 fi
196
197 _configure_quantum_debug_command
198
199 _cleanup_quantum
200}
201
202function create_nova_conf_quantum() {
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800203 iniset $NOVA_CONF DEFAULT network_api_class "nova.network.quantumv2.api.API"
204 iniset $NOVA_CONF DEFAULT quantum_admin_username "$Q_ADMIN_USERNAME"
205 iniset $NOVA_CONF DEFAULT quantum_admin_password "$SERVICE_PASSWORD"
206 iniset $NOVA_CONF DEFAULT quantum_admin_auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_SERVICE_HOST:$KEYSTONE_AUTH_PORT/v2.0"
207 iniset $NOVA_CONF DEFAULT quantum_auth_strategy "$Q_AUTH_STRATEGY"
208 iniset $NOVA_CONF DEFAULT quantum_admin_tenant_name "$SERVICE_TENANT_NAME"
209 iniset $NOVA_CONF DEFAULT quantum_url "http://$Q_HOST:$Q_PORT"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900210
211 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
212 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
213 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
214 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.QuantumLinuxBridgeVIFDriver"}
215 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
216 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"quantum.plugins.ryu.nova.vif.LibvirtOpenVswitchOFPRyuDriver"}
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800217 iniset $NOVA_CONF DEFAULT libvirt_ovs_integration_bridge "$OVS_BRIDGE"
218 iniset $NOVA_CONF DEFAULT linuxnet_ovs_ryu_api_host "$RYU_API_HOST:$RYU_API_PORT"
219 iniset $NOVA_CONF DEFAULT libvirt_ovs_ryu_api_host "$RYU_API_HOST:$RYU_API_PORT"
Sumit Naiksatam4b26d312013-01-04 10:32:54 -0800220 elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
221 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver"}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900222 fi
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800223 iniset $NOVA_CONF DEFAULT libvirt_vif_driver "$NOVA_VIF_DRIVER"
224 iniset $NOVA_CONF DEFAULT linuxnet_interface_driver "$LINUXNET_VIF_DRIVER"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900225 if is_service_enabled q-meta; then
Devananda van der Veen9bc47db2012-12-12 16:52:55 -0800226 iniset $NOVA_CONF DEFAULT service_quantum_metadata_proxy "True"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900227 fi
228}
229
230# create_quantum_accounts() - Set up common required quantum accounts
231
232# Tenant User Roles
233# ------------------------------------------------------------------
234# service quantum admin # if enabled
235
236# Migrated from keystone_data.sh
237function create_quantum_accounts() {
238
239 SERVICE_TENANT=$(keystone tenant-list | awk "/ $SERVICE_TENANT_NAME / { print \$2 }")
240 ADMIN_ROLE=$(keystone role-list | awk "/ admin / { print \$2 }")
241
242 if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then
243 QUANTUM_USER=$(keystone user-create \
244 --name=quantum \
245 --pass="$SERVICE_PASSWORD" \
246 --tenant_id $SERVICE_TENANT \
247 --email=quantum@example.com \
248 | grep " id " | get_field 2)
249 keystone user-role-add \
250 --tenant_id $SERVICE_TENANT \
251 --user_id $QUANTUM_USER \
252 --role_id $ADMIN_ROLE
253 if [[ "$KEYSTONE_CATALOG_BACKEND" = 'sql' ]]; then
254 QUANTUM_SERVICE=$(keystone service-create \
255 --name=quantum \
256 --type=network \
257 --description="Quantum Service" \
258 | grep " id " | get_field 2)
259 keystone endpoint-create \
260 --region RegionOne \
261 --service_id $QUANTUM_SERVICE \
262 --publicurl "http://$SERVICE_HOST:9696/" \
263 --adminurl "http://$SERVICE_HOST:9696/" \
264 --internalurl "http://$SERVICE_HOST:9696/"
265 fi
266 fi
267}
268
269function create_quantum_initial_network() {
270 TENANT_ID=$(keystone tenant-list | grep " demo " | get_field 1)
271
272 # Create a small network
273 # Since quantum command is executed in admin context at this point,
274 # ``--tenant_id`` needs to be specified.
275 NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
276 SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
277
278 if is_service_enabled q-l3; then
279 # Create a router, and add the private subnet as one of its interfaces
280 ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID router1 | grep ' id ' | get_field 2)
281 quantum router-interface-add $ROUTER_ID $SUBNET_ID
282 # Create an external network, and a subnet. Configure the external network as router gw
283 EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
284 EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
285 quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
286
287 if is_quantum_ovs_base_plugin "$Q_PLUGIN" && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
288 CIDR_LEN=${FLOATING_RANGE#*/}
289 sudo ip addr add $EXT_GW_IP/$CIDR_LEN dev $PUBLIC_BRIDGE
290 sudo ip link set $PUBLIC_BRIDGE up
291 ROUTER_GW_IP=`quantum port-list -c fixed_ips -c device_owner | grep router_gateway | awk -F '"' '{ print $8; }'`
292 sudo route add -net $FIXED_RANGE gw $ROUTER_GW_IP
293 fi
294 if [[ "$Q_USE_NAMESPACE" == "False" ]]; then
295 # Explicitly set router id in l3 agent configuration
296 iniset $Q_L3_CONF_FILE DEFAULT router_id $ROUTER_ID
297 fi
298 fi
299}
300
301# init_quantum() - Initialize databases, etc.
302function init_quantum() {
303 :
304}
305
306# install_quantum() - Collect source and prepare
307function install_quantum() {
308 git_clone $QUANTUM_REPO $QUANTUM_DIR $QUANTUM_BRANCH
309}
310
311# install_quantumclient() - Collect source and prepare
312function install_quantumclient() {
313 git_clone $QUANTUMCLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUMCLIENT_BRANCH
314}
315
316# install_quantum_agent_packages() - Collect source and prepare
317function install_quantum_agent_packages() {
318 if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
319 # Install deps
320 # FIXME add to ``files/apts/quantum``, but don't install if not needed!
321 if is_ubuntu; then
322 kernel_version=`cat /proc/version | cut -d " " -f3`
323 install_package make fakeroot dkms openvswitch-switch openvswitch-datapath-dkms linux-headers-$kernel_version
324 else
325 ### FIXME(dtroyer): Find RPMs for OpenVSwitch
326 echo "OpenVSwitch packages need to be located"
327 # Fedora does not started OVS by default
328 restart_service openvswitch
329 fi
330 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
331 install_package bridge-utils
332 fi
333}
334
335function is_quantum_ovs_base_plugin() {
336 local plugin=$1
Sumit Naiksatam4b26d312013-01-04 10:32:54 -0800337 if [[ ",openvswitch,ryu,bigswitch_floodlight," =~ ,${plugin}, ]]; then
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900338 return 0
339 fi
340 return 1
341}
342
343function setup_quantum() {
344 setup_develop $QUANTUM_DIR
345}
346
347function setup_quantumclient() {
348 setup_develop $QUANTUMCLIENT_DIR
349}
350
351# Start running processes, including screen
352function start_quantum_service_and_check() {
353 # Start the Quantum service
354 screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
355 echo "Waiting for Quantum to start..."
356 if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9696; do sleep 1; done"; then
357 echo "Quantum did not start"
358 exit 1
359 fi
360}
361
362# Start running processes, including screen
363function start_quantum_agents() {
364 # Start up the quantum agents if enabled
365 screen_it q-agt "python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
366 screen_it q-dhcp "python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE"
367 screen_it q-meta "python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE"
368 screen_it q-l3 "python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
369}
370
371# stop_quantum() - Stop running processes (non-screen)
372function stop_quantum() {
373 if is_service_enabled q-dhcp; then
374 pid=$(ps aux | awk '/[d]nsmasq.+interface=(tap|ns-)/ { print $2 }')
375 [ ! -z "$pid" ] && sudo kill -9 $pid
376 fi
377}
378
379# _cleanup_quantum() - Remove residual data files, anything left over from previous
380# runs that a clean run would need to clean up
381function _cleanup_quantum() {
382 :
383}
384
385# _configure_quantum_common()
386# Set common config for all quantum server and agents.
387# This MUST be called before other _configure_quantum_* functions.
388function _configure_quantum_common() {
389 # Put config files in ``QUANTUM_CONF_DIR`` for everyone to find
390 if [[ ! -d $QUANTUM_CONF_DIR ]]; then
391 sudo mkdir -p $QUANTUM_CONF_DIR
392 fi
Attila Fazekas91b8d132013-01-06 22:40:09 +0100393 sudo chown $STACK_USER $QUANTUM_CONF_DIR
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900394
395 cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF
396
397 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
398 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch
399 Q_PLUGIN_CONF_FILENAME=ovs_quantum_plugin.ini
400 Q_DB_NAME="ovs_quantum"
401 Q_PLUGIN_CLASS="quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
402 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
403 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/linuxbridge
404 Q_PLUGIN_CONF_FILENAME=linuxbridge_conf.ini
405 Q_DB_NAME="quantum_linux_bridge"
406 Q_PLUGIN_CLASS="quantum.plugins.linuxbridge.lb_quantum_plugin.LinuxBridgePluginV2"
407 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
408 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/ryu
409 Q_PLUGIN_CONF_FILENAME=ryu.ini
410 Q_DB_NAME="ovs_quantum"
411 Q_PLUGIN_CLASS="quantum.plugins.ryu.ryu_quantum_plugin.RyuQuantumPluginV2"
Sumit Naiksatam4b26d312013-01-04 10:32:54 -0800412 elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
413 Q_PLUGIN_CONF_PATH=etc/quantum/plugins/bigswitch
414 Q_PLUGIN_CONF_FILENAME=restproxy.ini
415 Q_DB_NAME="restproxy_quantum"
416 Q_PLUGIN_CLASS="quantum.plugins.bigswitch.plugin.QuantumRestProxyV2"
417 BS_FL_CONTROLLERS_PORT=${BS_FL_CONTROLLERS_PORT:-localhost:80}
418 BS_FL_CONTROLLER_TIMEOUT=${BS_FL_CONTROLLER_TIMEOUT:-10}
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900419 fi
420
421 if [[ $Q_PLUGIN_CONF_PATH == '' || $Q_PLUGIN_CONF_FILENAME == '' || $Q_PLUGIN_CLASS == '' ]]; then
422 echo "Quantum plugin not set.. exiting"
423 exit 1
424 fi
425
426 # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR``
427 mkdir -p /$Q_PLUGIN_CONF_PATH
428 Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
429 cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
430
431 database_connection_url dburl $Q_DB_NAME
432 iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection $dburl
433 unset dburl
434
435 _quantum_setup_rootwrap
436}
437
438function _configure_quantum_debug_command() {
439 if [[ "$Q_USE_DEBUG_COMMAND" != "True" ]]; then
440 return
441 fi
442
443 cp $QUANTUM_DIR/etc/l3_agent.ini $QUANTUM_TEST_CONFIG_FILE
444
445 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT verbose False
446 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT debug False
447 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
448 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT root_helper "$Q_RR_COMMAND"
449
450 _quantum_setup_keystone $QUANTUM_TEST_CONFIG_FILE DEFAULT set_auth_url
451 _quantum_setup_interface_driver $QUANTUM_TEST_CONFIG_FILE
452
453 if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
454 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
455 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
456 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT external_network_bridge ''
457 fi
458
459 if [[ "$Q_PLUGIN" = "ryu" ]]; then
460 iniset $QUANTUM_TEST_CONFIG_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
461 fi
462}
463
464function _configure_quantum_dhcp_agent() {
465 AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent"
466 Q_DHCP_CONF_FILE=$QUANTUM_CONF_DIR/dhcp_agent.ini
467
468 cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE
469
470 iniset $Q_DHCP_CONF_FILE DEFAULT verbose True
471 iniset $Q_DHCP_CONF_FILE DEFAULT debug True
472 iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
473 iniset $Q_DHCP_CONF_FILE DEFAULT state_path $DATA_DIR/quantum
474 iniset $Q_DHCP_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
475
476 _quantum_setup_keystone $Q_DHCP_CONF_FILE DEFAULT set_auth_url
477 _quantum_setup_interface_driver $Q_DHCP_CONF_FILE
478
479 if [[ "$Q_PLUGIN" = "ryu" ]]; then
480 iniset $Q_DHCP_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
481 fi
482}
483
484function _configure_quantum_l3_agent() {
485 AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
486 PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
487 Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini
488
489 cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
490
491 iniset $Q_L3_CONF_FILE DEFAULT verbose True
492 iniset $Q_L3_CONF_FILE DEFAULT debug True
493 iniset $Q_L3_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE
494 iniset $Q_L3_CONF_FILE DEFAULT state_path $DATA_DIR/quantum
495 iniset $Q_L3_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
496
497 _quantum_setup_keystone $Q_L3_CONF_FILE DEFAULT set_auth_url
498 _quantum_setup_interface_driver $Q_L3_CONF_FILE
499
500 if is_quantum_ovs_base_plugin "$Q_PLUGIN"; then
501 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge $PUBLIC_BRIDGE
502 _quantum_setup_external_bridge $PUBLIC_BRIDGE
503 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
504 iniset $Q_L3_CONF_FILE DEFAULT external_network_bridge ''
505 fi
506
507 if [[ "$Q_PLUGIN" = "ryu" ]]; then
508 iniset $Q_L3_CONF_FILE DEFAULT ryu_api_host $RYU_API_HOST:$RYU_API_PORT
509 fi
510}
511
512function _configure_quantum_metadata_agent() {
513 AGENT_META_BINARY="$QUANTUM_DIR/bin/quantum-metadata-agent"
514 Q_META_CONF_FILE=$QUANTUM_CONF_DIR/metadata_agent.ini
515
516 cp $QUANTUM_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE
517
518 iniset $Q_META_CONF_FILE DEFAULT verbose True
519 iniset $Q_META_CONF_FILE DEFAULT debug True
520 iniset $Q_META_CONF_FILE DEFAULT state_path $DATA_DIR/quantum
521 iniset $Q_META_CONF_FILE DEFAULT nova_metadata_ip $Q_META_DATA_IP
522 iniset $Q_META_CONF_FILE DEFAULT root_helper "$Q_RR_COMMAND"
523
524 _quantum_setup_keystone $Q_META_CONF_FILE DEFAULT set_auth_url
525}
526
527# _configure_quantum_plugin_agent() - Set config files for quantum plugin agent
528# It is called when q-agt is enabled.
529function _configure_quantum_plugin_agent() {
530 # Configure agent for plugin
531 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
532 _configure_quantum_plugin_agent_openvswitch
533 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
534 _configure_quantum_plugin_agent_linuxbridge
535 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
536 _configure_quantum_plugin_agent_ryu
537 fi
538
539 iniset /$Q_PLUGIN_CONF_FILE AGENT root_helper "$Q_RR_COMMAND"
540}
541
542function _configure_quantum_plugin_agent_linuxbridge() {
543 # Setup physical network interface mappings. Override
544 # ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc`` for more
545 # complex physical network configurations.
546 if [[ "$LB_INTERFACE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$LB_PHYSICAL_INTERFACE" != "" ]]; then
547 LB_INTERFACE_MAPPINGS=$PHYSICAL_NETWORK:$LB_PHYSICAL_INTERFACE
548 fi
549 if [[ "$LB_INTERFACE_MAPPINGS" != "" ]]; then
550 iniset /$Q_PLUGIN_CONF_FILE LINUX_BRIDGE physical_interface_mappings $LB_INTERFACE_MAPPINGS
551 fi
552 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-linuxbridge-agent"
553}
554
555function _configure_quantum_plugin_agent_openvswitch() {
556 # Setup integration bridge
557 OVS_BRIDGE=${OVS_BRIDGE:-br-int}
558 _quantum_setup_ovs_bridge $OVS_BRIDGE
559
560 # Setup agent for tunneling
561 if [[ "$OVS_ENABLE_TUNNELING" = "True" ]]; then
562 # Verify tunnels are supported
563 # REVISIT - also check kernel module support for GRE and patch ports
564 OVS_VERSION=`ovs-vsctl --version | head -n 1 | awk '{print $4;}'`
565 if [ $OVS_VERSION \< "1.4" ] && ! is_service_enabled q-svc ; then
566 echo "You are running OVS version $OVS_VERSION."
567 echo "OVS 1.4+ is required for tunneling between multiple hosts."
568 exit 1
569 fi
570 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
571 iniset /$Q_PLUGIN_CONF_FILE OVS local_ip $HOST_IP
572 fi
573
574 # Setup physical network bridge mappings. Override
575 # ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc`` for more
576 # complex physical network configurations.
577 if [[ "$OVS_BRIDGE_MAPPINGS" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]] && [[ "$OVS_PHYSICAL_BRIDGE" != "" ]]; then
578 OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE
579
580 # Configure bridge manually with physical interface as port for multi-node
581 sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE
582 fi
583 if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then
584 iniset /$Q_PLUGIN_CONF_FILE OVS bridge_mappings $OVS_BRIDGE_MAPPINGS
585 fi
586 AGENT_BINARY="$QUANTUM_DIR/bin/quantum-openvswitch-agent"
587}
588
589function _configure_quantum_plugin_agent_ryu() {
590 # Set up integration bridge
591 OVS_BRIDGE=${OVS_BRIDGE:-br-int}
592 _quantum_setup_ovs_bridge $OVS_BRIDGE
593 if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
594 sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE
595 fi
596 AGENT_BINARY="$QUANTUM_DIR/quantum/plugins/ryu/agent/ryu_quantum_agent.py"
597}
598
599# Quantum RPC support - must be updated prior to starting any of the services
600function _configure_quantum_rpc() {
601 iniset $QUANTUM_CONF DEFAULT control_exchange quantum
602 if is_service_enabled qpid ; then
603 iniset $QUANTUM_CONF DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid
604 elif is_service_enabled zeromq; then
605 iniset $QUANTUM_CONF DEFAULT rpc_backend quantum.openstack.common.rpc.impl_zmq
606 elif [ -n "$RABBIT_HOST" ] && [ -n "$RABBIT_PASSWORD" ]; then
607 iniset $QUANTUM_CONF DEFAULT rabbit_host $RABBIT_HOST
608 iniset $QUANTUM_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
609 fi
610}
611
612# _configure_quantum_service() - Set config files for quantum service
613# It is called when q-svc is enabled.
614function _configure_quantum_service() {
615 Q_API_PASTE_FILE=$QUANTUM_CONF_DIR/api-paste.ini
616 Q_POLICY_FILE=$QUANTUM_CONF_DIR/policy.json
617
618 cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
619 cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
620
621 if is_service_enabled $DATABASE_BACKENDS; then
622 recreate_database $Q_DB_NAME utf8
623 else
624 echo "A database must be enabled in order to use the $Q_PLUGIN Quantum plugin."
625 exit 1
626 fi
627
628 # Update either configuration file with plugin
629 iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
630
631 iniset $QUANTUM_CONF DEFAULT verbose True
632 iniset $QUANTUM_CONF DEFAULT debug True
633 iniset $QUANTUM_CONF DEFAULT allow_overlapping_ips $Q_ALLOW_OVERLAPPING_IP
634
635 iniset $QUANTUM_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
636 _quantum_setup_keystone $Q_API_PASTE_FILE filter:authtoken
637
638 # Configure plugin
639 if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
640 if [[ "$ENABLE_TENANT_TUNNELS" = "True" ]]; then
641 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type gre
642 iniset /$Q_PLUGIN_CONF_FILE OVS tunnel_id_ranges $TENANT_TUNNEL_RANGES
643 elif [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
644 iniset /$Q_PLUGIN_CONF_FILE OVS tenant_network_type vlan
645 else
646 echo "WARNING - The openvswitch plugin is using local tenant networks, with no connectivity between hosts."
647 fi
648
649 # Override ``OVS_VLAN_RANGES`` and ``OVS_BRIDGE_MAPPINGS`` in ``localrc``
650 # for more complex physical network configurations.
651 if [[ "$OVS_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
652 OVS_VLAN_RANGES=$PHYSICAL_NETWORK
653 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
654 OVS_VLAN_RANGES=$OVS_VLAN_RANGES:$TENANT_VLAN_RANGE
655 fi
656 fi
657 if [[ "$OVS_VLAN_RANGES" != "" ]]; then
658 iniset /$Q_PLUGIN_CONF_FILE OVS network_vlan_ranges $OVS_VLAN_RANGES
659 fi
660
661 # Enable tunnel networks if selected
662 if [[ $OVS_ENABLE_TUNNELING = "True" ]]; then
663 iniset /$Q_PLUGIN_CONF_FILE OVS enable_tunneling True
664 fi
665 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
666 if [[ "$ENABLE_TENANT_VLANS" = "True" ]]; then
667 iniset /$Q_PLUGIN_CONF_FILE VLANS tenant_network_type vlan
668 else
669 echo "WARNING - The linuxbridge plugin is using local tenant networks, with no connectivity between hosts."
670 fi
671
672 # Override ``LB_VLAN_RANGES`` and ``LB_INTERFACE_MAPPINGS`` in ``localrc``
673 # for more complex physical network configurations.
674 if [[ "$LB_VLAN_RANGES" = "" ]] && [[ "$PHYSICAL_NETWORK" != "" ]]; then
675 LB_VLAN_RANGES=$PHYSICAL_NETWORK
676 if [[ "$TENANT_VLAN_RANGE" != "" ]]; then
677 LB_VLAN_RANGES=$LB_VLAN_RANGES:$TENANT_VLAN_RANGE
678 fi
679 fi
680 if [[ "$LB_VLAN_RANGES" != "" ]]; then
681 iniset /$Q_PLUGIN_CONF_FILE VLANS network_vlan_ranges $LB_VLAN_RANGES
682 fi
683 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
684 iniset /$Q_PLUGIN_CONF_FILE OVS openflow_controller $RYU_OFP_HOST:$RYU_OFP_PORT
685 iniset /$Q_PLUGIN_CONF_FILE OVS openflow_rest_api $RYU_API_HOST:$RYU_API_PORT
Sumit Naiksatam4b26d312013-01-04 10:32:54 -0800686 elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
687 iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servers $BS_FL_CONTROLLERS_PORT
688 iniset /$Q_PLUGIN_CONF_FILE RESTPROXY servertimeout $BS_FL_CONTROLLER_TIMEOUT
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900689 fi
690}
691
692# Utility Functions
693#------------------
694
695# _quantum_setup_rootwrap() - configure Quantum's rootwrap
696function _quantum_setup_rootwrap() {
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800697 if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
698 return
699 fi
700 # Deploy new rootwrap filters files (owned by root).
701 # Wipe any existing rootwrap.d files first
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600702 Q_CONF_ROOTWRAP_D=$QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800703 if [[ -d $Q_CONF_ROOTWRAP_D ]]; then
704 sudo rm -rf $Q_CONF_ROOTWRAP_D
705 fi
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600706 # Deploy filters to $QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800707 mkdir -p -m 755 $Q_CONF_ROOTWRAP_D
708 cp -pr $QUANTUM_DIR/etc/quantum/rootwrap.d/* $Q_CONF_ROOTWRAP_D/
709 sudo chown -R root:root $Q_CONF_ROOTWRAP_D
710 sudo chmod 644 $Q_CONF_ROOTWRAP_D/*
Dean Troyer60e9c0a2012-12-06 15:52:52 -0600711 # Set up rootwrap.conf, pointing to $QUANTUM_CONF_DIR/rootwrap.d
Nachi Uenoeb1aa3d2012-12-06 11:55:29 -0800712 sudo cp -p $QUANTUM_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE
713 sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE
714 sudo chown root:root $Q_RR_CONF_FILE
715 sudo chmod 0644 $Q_RR_CONF_FILE
716 # Specify rootwrap.conf as first parameter to quantum-rootwrap
717 ROOTWRAP_SUDOER_CMD="$QUANTUM_ROOTWRAP $Q_RR_CONF_FILE *"
718
719 # Set up the rootwrap sudoers for quantum
720 TEMPFILE=`mktemp`
721 echo "$USER ALL=(root) NOPASSWD: $ROOTWRAP_SUDOER_CMD" >$TEMPFILE
722 chmod 0440 $TEMPFILE
723 sudo chown root:root $TEMPFILE
724 sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap
725}
726
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700727# Configures keystone integration for quantum service and agents
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900728function _quantum_setup_keystone() {
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700729 local conf_file=$1
730 local section=$2
731 local use_auth_url=$3
732 if [[ -n $use_auth_url ]]; then
733 iniset $conf_file $section auth_url "$KEYSTONE_SERVICE_PROTOCOL://$KEYSTONE_AUTH_HOST:$KEYSTONE_AUTH_PORT/v2.0"
734 else
735 iniset $conf_file $section auth_host $KEYSTONE_SERVICE_HOST
736 iniset $conf_file $section auth_port $KEYSTONE_AUTH_PORT
737 iniset $conf_file $section auth_protocol $KEYSTONE_SERVICE_PROTOCOL
738 fi
739 iniset $conf_file $section admin_tenant_name $SERVICE_TENANT_NAME
740 iniset $conf_file $section admin_user $Q_ADMIN_USERNAME
741 iniset $conf_file $section admin_password $SERVICE_PASSWORD
Akihiro MOTOKI5e3deb62012-12-11 17:09:02 +0900742 iniset $conf_file $section signing_dir $QUANTUM_AUTH_CACHE_DIR
743 # Create cache dir
744 sudo mkdir -p $QUANTUM_AUTH_CACHE_DIR
Attila Fazekas91b8d132013-01-06 22:40:09 +0100745 sudo chown $STACK_USER $QUANTUM_AUTH_CACHE_DIR
Vishvananda Ishaya23431f32012-12-12 15:57:33 -0800746 rm -f $QUANTUM_AUTH_CACHE_DIR/*
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700747}
748
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900749function _quantum_setup_ovs_bridge() {
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700750 local bridge=$1
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900751 quantum-ovs-cleanup --ovs_integration_bridge $bridge
752 sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700753 sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
754}
755
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900756function _quantum_setup_interface_driver() {
757 local conf_file=$1
758 if [[ "$Q_PLUGIN" == "openvswitch" ]]; then
759 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
760 elif [[ "$Q_PLUGIN" = "linuxbridge" ]]; then
761 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.BridgeInterfaceDriver
762 elif [[ "$Q_PLUGIN" = "ryu" ]]; then
763 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.RyuInterfaceDriver
Sumit Naiksatam4b26d312013-01-04 10:32:54 -0800764 elif [[ "$Q_PLUGIN" = "bigswitch_floodlight" ]]; then
765 iniset $conf_file DEFAULT interface_driver quantum.agent.linux.interface.OVSInterfaceDriver
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900766 fi
767}
768
769function _quantum_setup_external_bridge() {
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000770 local bridge=$1
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900771 quantum-ovs-cleanup --external_network_bridge $bridge
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000772 sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000773 # ensure no IP is configured on the public bridge
774 sudo ip addr flush dev $bridge
775}
776
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900777# Functions for Quantum Exercises
778#--------------------------------
779
780function delete_probe() {
781 local from_net="$1"
782 net_id=`_get_net_id $from_net`
783 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}'`
784 quantum-debug --os-tenant-name admin --os-username admin probe-delete $probe_id
785}
786
787function setup_quantum_debug() {
788 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
789 public_net_id=`_get_net_id $PUBLIC_NETWORK_NAME`
790 quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create $public_net_id
791 private_net_id=`_get_net_id $PRIVATE_NETWORK_NAME`
792 quantum-debug --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD probe-create $private_net_id
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000793 fi
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900794}
795
796function teardown_quantum_debug() {
797 delete_probe $PUBLIC_NETWORK_NAME
798 delete_probe $PRIVATE_NETWORK_NAME
Yoshihiro Kaneko602cf9b2012-07-23 06:27:36 +0000799}
800
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700801function _get_net_id() {
802 quantum --os-tenant-name admin --os-username admin --os-password $ADMIN_PASSWORD net-list | grep $1 | awk '{print $2}'
803}
804
805function _get_probe_cmd_prefix() {
806 local from_net="$1"
807 net_id=`_get_net_id $from_net`
808 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 -0800809 echo "$Q_RR_COMMAND ip netns exec qprobe-$probe_id"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700810}
811
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700812function _ping_check_quantum() {
813 local from_net=$1
814 local ip=$2
815 local timeout_sec=$3
816 local expected=${4:-"True"}
817 local check_command=""
818 probe_cmd=`_get_probe_cmd_prefix $from_net`
819 if [[ "$expected" = "True" ]]; then
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800820 check_command="while ! $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700821 else
Nachi Ueno8bc21f62012-11-19 22:04:28 -0800822 check_command="while $probe_cmd ping -w 1 -c 1 $ip; do sleep 1; done"
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700823 fi
824 if ! timeout $timeout_sec sh -c "$check_command"; then
825 if [[ "$expected" = "True" ]]; then
826 echo "[Fail] Couldn't ping server"
827 else
828 echo "[Fail] Could ping server"
829 fi
830 exit 1
831 fi
832}
833
834# ssh check
835function _ssh_check_quantum() {
836 local from_net=$1
837 local key_file=$2
838 local ip=$3
839 local user=$4
840 local timeout_sec=$5
841 local probe_cmd = ""
842 probe_cmd=`_get_probe_cmd_prefix $from_net`
843 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
844 echo "server didn't become ssh-able!"
845 exit 1
846 fi
847}
848
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900849# Quantum 3rd party programs
850#---------------------------
851# A comma-separated list of 3rd party programs
Sumit Naiksatam4b26d312013-01-04 10:32:54 -0800852QUANTUM_THIRD_PARTIES="ryu,bigswitch_floodlight"
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900853for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
854 source lib/$third_party
855done
856
857# configure_quantum_third_party() - Set config files, create data dirs, etc
858function configure_quantum_third_party() {
859 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
860 if is_service_enabled $third_party; then
861 configure_${third_party}
862 fi
863 done
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700864}
865
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900866# init_quantum_third_party() - Initialize databases, etc.
867function init_quantum_third_party() {
868 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
869 if is_service_enabled $third_party; then
870 init_${third_party}
871 fi
872 done
Nachi Ueno5db5bfa2012-10-29 11:25:29 -0700873}
874
Akihiro MOTOKI66afb472012-12-21 15:34:13 +0900875# install_quantum_third_party() - Collect source and prepare
876function install_quantum_third_party() {
877 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
878 if is_service_enabled $third_party; then
879 install_${third_party}
880 fi
881 done
882}
883
884# start_quantum_third_party() - Start running processes, including screen
885function start_quantum_third_party() {
886 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
887 if is_service_enabled $third_party; then
888 start_${third_party}
889 fi
890 done
891}
892
893# stop_quantum_third_party - Stop running processes (non-screen)
894function stop_quantum_third_party() {
895 for third_party in ${QUANTUM_THIRD_PARTIES//,/ }; do
896 if is_service_enabled $third_party; then
897 stop_${third_party}
898 fi
899 done
900}
901
902
Salvatore Orlandod6767d02012-08-31 04:55:20 -0700903# Restore xtrace
904$XTRACE