Browse code

Quantum cleanups

* Set base default env vars in lib/quantum
* Rename common dirs to match devstack conventions
Q_CONF_FILE -> QUANTUM_CONF
QUANTUM_CLIENT_* -> QUANTUMCLIENT_*

Change-Id: I7a2a92b50ef953195f078ac62cb975f28892c05c

Dean Troyer authored on 2012/12/07 06:52:52
Showing 3 changed files
... ...
@@ -1,17 +1,69 @@
1 1
 # lib/quantum
2 2
 # functions - funstions specific to quantum
3 3
 
4
+# Dependencies:
5
+# ``functions`` file
6
+# ``DEST`` must be defined
7
+
8
+
9
+# Quantum Networking
10
+# ------------------
11
+
12
+# Make sure that quantum is enabled in ``ENABLED_SERVICES``.  If you want
13
+# to run Quantum on this host, make sure that q-svc is also in
14
+# ``ENABLED_SERVICES``.
15
+#
16
+# If you're planning to use the Quantum openvswitch plugin, set
17
+# ``Q_PLUGIN`` to "openvswitch" and make sure the q-agt service is enabled
18
+# in ``ENABLED_SERVICES``.  If you're planning to use the Quantum
19
+# linuxbridge plugin, set ``Q_PLUGIN`` to "linuxbridge" and make sure the
20
+# q-agt service is enabled in ``ENABLED_SERVICES``.
21
+#
22
+# See "Quantum Network Configuration" below for additional variables
23
+# that must be set in localrc for connectivity across hosts with
24
+# Quantum.
25
+#
26
+# With Quantum networking the NET_MAN variable is ignored.
27
+
28
+
4 29
 # Save trace setting
5 30
 XTRACE=$(set +o | grep xtrace)
6 31
 set +o xtrace
7 32
 
33
+
34
+# Defaults
35
+# --------
36
+
37
+# Set up default directories
8 38
 QUANTUM_DIR=$DEST/quantum
9
-export QUANTUM_TEST_CONFIG_FILE=${QUANTUM_TEST_CONFIG_FILE:-"/etc/quantum/debug.ini"}
39
+QUANTUMCLIENT_DIR=$DEST/python-quantumclient
10 40
 QUANTUM_AUTH_CACHE_DIR=${QUANTUM_AUTH_CACHE_DIR:-/var/cache/quantum}
11 41
 
42
+QUANTUM_CONF_DIR=/etc/quantum
43
+QUANTUM_CONF=$QUANTUM_CONF_DIR/quantum.conf
44
+export QUANTUM_TEST_CONFIG_FILE=${QUANTUM_TEST_CONFIG_FILE:-"$QUANTUM_CONF_DIR/debug.ini"}
45
+
46
+# Default Quantum Plugin
47
+Q_PLUGIN=${Q_PLUGIN:-openvswitch}
48
+# Default Quantum Port
49
+Q_PORT=${Q_PORT:-9696}
50
+# Default Quantum Host
51
+Q_HOST=${Q_HOST:-$HOST_IP}
52
+# Which Quantum API nova should use
53
+# Default admin username
54
+Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum}
55
+# Default auth strategy
56
+Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
57
+# Use namespace or not
58
+Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
59
+Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
60
+# Meta data IP
61
+Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
62
+# Use quantum-debug command
63
+Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
64
+
12 65
 if is_service_enabled quantum; then
13
-    Q_CONF_FILE=/etc/quantum/quantum.conf
14
-    Q_RR_CONF_FILE=/etc/quantum/rootwrap.conf
66
+    Q_RR_CONF_FILE=$QUANTUM_CONF_DIR/rootwrap.conf
15 67
     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
16 68
         Q_RR_COMMAND="sudo"
17 69
     else
... ...
@@ -20,6 +72,10 @@ if is_service_enabled quantum; then
20 20
     fi
21 21
 fi
22 22
 
23
+
24
+# Entry Points
25
+# ------------
26
+
23 27
 # configure_quantum_rootwrap() - configure Quantum's rootwrap
24 28
 function configure_quantum_rootwrap() {
25 29
     if [[ "$Q_USE_ROOTWRAP" == "False" ]]; then
... ...
@@ -27,16 +83,16 @@ function configure_quantum_rootwrap() {
27 27
     fi
28 28
     # Deploy new rootwrap filters files (owned by root).
29 29
     # Wipe any existing rootwrap.d files first
30
-    Q_CONF_ROOTWRAP_D=/etc/quantum/rootwrap.d
30
+    Q_CONF_ROOTWRAP_D=$QUANTUM_CONF_DIR/rootwrap.d
31 31
     if [[ -d $Q_CONF_ROOTWRAP_D ]]; then
32 32
         sudo rm -rf $Q_CONF_ROOTWRAP_D
33 33
     fi
34
-    # Deploy filters to /etc/quantum/rootwrap.d
34
+    # Deploy filters to $QUANTUM_CONF_DIR/rootwrap.d
35 35
     mkdir -p -m 755 $Q_CONF_ROOTWRAP_D
36 36
     cp -pr $QUANTUM_DIR/etc/quantum/rootwrap.d/* $Q_CONF_ROOTWRAP_D/
37 37
     sudo chown -R root:root $Q_CONF_ROOTWRAP_D
38 38
     sudo chmod 644 $Q_CONF_ROOTWRAP_D/*
39
-    # Set up rootwrap.conf, pointing to /etc/quantum/rootwrap.d
39
+    # Set up rootwrap.conf, pointing to $QUANTUM_CONF_DIR/rootwrap.d
40 40
     sudo cp -p $QUANTUM_DIR/etc/rootwrap.conf $Q_RR_CONF_FILE
41 41
     sudo sed -e "s:^filters_path=.*$:filters_path=$Q_CONF_ROOTWRAP_D:" -i $Q_RR_CONF_FILE
42 42
     sudo chown root:root $Q_RR_CONF_FILE
... ...
@@ -52,7 +108,6 @@ function configure_quantum_rootwrap() {
52 52
     sudo mv $TEMPFILE /etc/sudoers.d/quantum-rootwrap
53 53
 }
54 54
 
55
-
56 55
 # Configures keystone integration for quantum service and agents
57 56
 function quantum_setup_keystone() {
58 57
     local conf_file=$1
... ...
@@ -321,26 +321,6 @@ HORIZON_DIR=$DEST/horizon
321 321
 OPENSTACKCLIENT_DIR=$DEST/python-openstackclient
322 322
 NOVNC_DIR=$DEST/noVNC
323 323
 SWIFT3_DIR=$DEST/swift3
324
-QUANTUM_CLIENT_DIR=$DEST/python-quantumclient
325
-
326
-# Default Quantum Plugin
327
-Q_PLUGIN=${Q_PLUGIN:-openvswitch}
328
-# Default Quantum Port
329
-Q_PORT=${Q_PORT:-9696}
330
-# Default Quantum Host
331
-Q_HOST=${Q_HOST:-$HOST_IP}
332
-# Which Quantum API nova should use
333
-# Default admin username
334
-Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum}
335
-# Default auth strategy
336
-Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone}
337
-# Use namespace or not
338
-Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True}
339
-Q_USE_ROOTWRAP=${Q_USE_ROOTWRAP:-True}
340
-# Meta data IP
341
-Q_META_DATA_IP=${Q_META_DATA_IP:-$HOST_IP}
342
-# Use quantum-debug command
343
-Q_USE_DEBUG_COMMAND=${Q_USE_DEBUG_COMMAND:-False}
344 324
 
345 325
 RYU_DIR=$DEST/ryu
346 326
 # Ryu API Host
... ...
@@ -458,26 +438,6 @@ FLAT_INTERFACE=${FLAT_INTERFACE-$GUEST_INTERFACE_DEFAULT}
458 458
 ## FIXME(ja): should/can we check that FLAT_INTERFACE is sane?
459 459
 
460 460
 
461
-# Quantum Networking
462
-# ------------------
463
-
464
-# Make sure that quantum is enabled in ENABLED_SERVICES.  If you want
465
-# to run Quantum on this host, make sure that q-svc is also in
466
-# ENABLED_SERVICES.
467
-#
468
-# If you're planning to use the Quantum openvswitch plugin, set
469
-# Q_PLUGIN to "openvswitch" and make sure the q-agt service is enabled
470
-# in ENABLED_SERVICES.  If you're planning to use the Quantum
471
-# linuxbridge plugin, set Q_PLUGIN to "linuxbridge" and make sure the
472
-# q-agt service is enabled in ENABLED_SERVICES.
473
-#
474
-# See "Quantum Network Configuration" below for additional variables
475
-# that must be set in localrc for connectivity across hosts with
476
-# Quantum.
477
-#
478
-# With Quantum networking the NET_MAN variable is ignored.
479
-
480
-
481 461
 # Database Configuration
482 462
 # ----------------------
483 463
 
... ...
@@ -805,7 +765,7 @@ if is_service_enabled horizon; then
805 805
     install_horizon
806 806
 fi
807 807
 if is_service_enabled quantum; then
808
-    git_clone $QUANTUM_CLIENT_REPO $QUANTUM_CLIENT_DIR $QUANTUM_CLIENT_BRANCH
808
+    git_clone $QUANTUMCLIENT_REPO $QUANTUMCLIENT_DIR $QUANTUMCLIENT_BRANCH
809 809
 fi
810 810
 if is_service_enabled quantum; then
811 811
     # quantum
... ...
@@ -864,7 +824,7 @@ if is_service_enabled horizon; then
864 864
     configure_horizon
865 865
 fi
866 866
 if is_service_enabled quantum; then
867
-    setup_develop $QUANTUM_CLIENT_DIR
867
+    setup_develop $QUANTUMCLIENT_DIR
868 868
     setup_develop $QUANTUM_DIR
869 869
 fi
870 870
 if is_service_enabled heat; then
... ...
@@ -1119,11 +1079,11 @@ if is_service_enabled quantum; then
1119 1119
     # Example: ``OVS_ENABLE_TUNNELING=True``
1120 1120
     OVS_ENABLE_TUNNELING=${OVS_ENABLE_TUNNELING:-$ENABLE_TENANT_TUNNELS}
1121 1121
 
1122
-    # Put config files in ``/etc/quantum`` for everyone to find
1123
-    if [[ ! -d /etc/quantum ]]; then
1124
-        sudo mkdir -p /etc/quantum
1122
+    # Put config files in ``QUANTUM_CONF_DIR`` for everyone to find
1123
+    if [[ ! -d $QUANTUM_CONF_DIR ]]; then
1124
+        sudo mkdir -p $QUANTUM_CONF_DIR
1125 1125
     fi
1126
-    sudo chown `whoami` /etc/quantum
1126
+    sudo chown `whoami` $QUANTUM_CONF_DIR
1127 1127
 
1128 1128
     if [[ "$Q_PLUGIN" = "openvswitch" ]]; then
1129 1129
         Q_PLUGIN_CONF_PATH=etc/quantum/plugins/openvswitch
... ...
@@ -1147,7 +1107,7 @@ if is_service_enabled quantum; then
1147 1147
         exit 1
1148 1148
     fi
1149 1149
 
1150
-    # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``/etc/quantum``
1150
+    # If needed, move config file from ``$QUANTUM_DIR/etc/quantum`` to ``QUANTUM_CONF_DIR``
1151 1151
     mkdir -p /$Q_PLUGIN_CONF_PATH
1152 1152
     Q_PLUGIN_CONF_FILE=$Q_PLUGIN_CONF_PATH/$Q_PLUGIN_CONF_FILENAME
1153 1153
     cp $QUANTUM_DIR/$Q_PLUGIN_CONF_FILE /$Q_PLUGIN_CONF_FILE
... ...
@@ -1156,14 +1116,14 @@ if is_service_enabled quantum; then
1156 1156
     iniset /$Q_PLUGIN_CONF_FILE DATABASE sql_connection $dburl
1157 1157
     unset dburl
1158 1158
 
1159
-    cp $QUANTUM_DIR/etc/quantum.conf $Q_CONF_FILE
1159
+    cp $QUANTUM_DIR/etc/quantum.conf $QUANTUM_CONF
1160 1160
     configure_quantum_rootwrap
1161 1161
 fi
1162 1162
 
1163 1163
 # Quantum service (for controller node)
1164 1164
 if is_service_enabled q-svc; then
1165
-    Q_API_PASTE_FILE=/etc/quantum/api-paste.ini
1166
-    Q_POLICY_FILE=/etc/quantum/policy.json
1165
+    Q_API_PASTE_FILE=$QUANTUM_CONF_DIR/api-paste.ini
1166
+    Q_POLICY_FILE=$QUANTUM_CONF_DIR/policy.json
1167 1167
 
1168 1168
     cp $QUANTUM_DIR/etc/api-paste.ini $Q_API_PASTE_FILE
1169 1169
     cp $QUANTUM_DIR/etc/policy.json $Q_POLICY_FILE
... ...
@@ -1176,9 +1136,9 @@ if is_service_enabled q-svc; then
1176 1176
     fi
1177 1177
 
1178 1178
     # Update either configuration file with plugin
1179
-    iniset $Q_CONF_FILE DEFAULT core_plugin $Q_PLUGIN_CLASS
1179
+    iniset $QUANTUM_CONF DEFAULT core_plugin $Q_PLUGIN_CLASS
1180 1180
 
1181
-    iniset $Q_CONF_FILE DEFAULT auth_strategy $Q_AUTH_STRATEGY
1181
+    iniset $QUANTUM_CONF DEFAULT auth_strategy $Q_AUTH_STRATEGY
1182 1182
     quantum_setup_keystone $Q_API_PASTE_FILE filter:authtoken
1183 1183
 
1184 1184
     # Configure plugin
... ...
@@ -1295,7 +1255,7 @@ fi
1295 1295
 if is_service_enabled q-dhcp; then
1296 1296
     AGENT_DHCP_BINARY="$QUANTUM_DIR/bin/quantum-dhcp-agent"
1297 1297
 
1298
-    Q_DHCP_CONF_FILE=/etc/quantum/dhcp_agent.ini
1298
+    Q_DHCP_CONF_FILE=$QUANTUM_CONF_DIR/dhcp_agent.ini
1299 1299
 
1300 1300
     cp $QUANTUM_DIR/etc/dhcp_agent.ini $Q_DHCP_CONF_FILE
1301 1301
 
... ...
@@ -1325,7 +1285,7 @@ fi
1325 1325
 if is_service_enabled q-l3; then
1326 1326
     AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
1327 1327
     PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
1328
-    Q_L3_CONF_FILE=/etc/quantum/l3_agent.ini
1328
+    Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini
1329 1329
 
1330 1330
     cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE
1331 1331
 
... ...
@@ -1361,7 +1321,7 @@ fi
1361 1361
 #Quantum Metadata
1362 1362
 if is_service_enabled q-meta; then
1363 1363
     AGENT_META_BINARY="$QUANTUM_DIR/bin/quantum-metadata-agent"
1364
-    Q_META_CONF_FILE=/etc/quantum/metadata_agent.ini
1364
+    Q_META_CONF_FILE=$QUANTUM_CONF_DIR/metadata_agent.ini
1365 1365
 
1366 1366
     cp $QUANTUM_DIR/etc/metadata_agent.ini $Q_META_CONF_FILE
1367 1367
 
... ...
@@ -1381,14 +1341,14 @@ fi
1381 1381
 
1382 1382
 # Quantum RPC support - must be updated prior to starting any of the services
1383 1383
 if is_service_enabled quantum; then
1384
-    iniset $Q_CONF_FILE DEFAULT control_exchange quantum
1384
+    iniset $QUANTUM_CONF DEFAULT control_exchange quantum
1385 1385
     if is_service_enabled qpid ; then
1386
-        iniset $Q_CONF_FILE DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid
1386
+        iniset $QUANTUM_CONF DEFAULT rpc_backend quantum.openstack.common.rpc.impl_qpid
1387 1387
     elif is_service_enabled zeromq; then
1388
-        iniset $Q_CONF_FILE DEFAULT rpc_backend quantum.openstack.common.rpc.impl_zmq
1388
+        iniset $QUANTUM_CONF DEFAULT rpc_backend quantum.openstack.common.rpc.impl_zmq
1389 1389
     elif [ -n "$RABBIT_HOST" ] &&  [ -n "$RABBIT_PASSWORD" ]; then
1390
-        iniset $Q_CONF_FILE DEFAULT rabbit_host $RABBIT_HOST
1391
-        iniset $Q_CONF_FILE DEFAULT rabbit_password $RABBIT_PASSWORD
1390
+        iniset $QUANTUM_CONF DEFAULT rabbit_host $RABBIT_HOST
1391
+        iniset $QUANTUM_CONF DEFAULT rabbit_password $RABBIT_PASSWORD
1392 1392
     fi
1393 1393
     if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
1394 1394
         cp $QUANTUM_DIR/etc/l3_agent.ini $QUANTUM_TEST_CONFIG_FILE
... ...
@@ -1598,7 +1558,7 @@ fi
1598 1598
 if is_service_enabled q-svc; then
1599 1599
     echo_summary "Starting Quantum"
1600 1600
     # Start the Quantum service
1601
-    screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
1601
+    screen_it q-svc "cd $QUANTUM_DIR && python $QUANTUM_DIR/bin/quantum-server --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
1602 1602
     echo "Waiting for Quantum to start..."
1603 1603
     if ! timeout $SERVICE_TIMEOUT sh -c "while ! http_proxy= wget -q -O- http://127.0.0.1:9696; do sleep 1; done"; then
1604 1604
       echo "Quantum did not start"
... ...
@@ -1650,10 +1610,10 @@ elif is_service_enabled $DATABASE_BACKENDS && is_service_enabled n-net; then
1650 1650
 fi
1651 1651
 
1652 1652
 # Start up the quantum agents if enabled
1653
-screen_it q-agt "python $AGENT_BINARY --config-file $Q_CONF_FILE --config-file /$Q_PLUGIN_CONF_FILE"
1654
-screen_it q-dhcp "python $AGENT_DHCP_BINARY --config-file $Q_CONF_FILE --config-file=$Q_DHCP_CONF_FILE"
1655
-screen_it q-meta "python $AGENT_META_BINARY --config-file $Q_CONF_FILE --config-file=$Q_META_CONF_FILE"
1656
-screen_it q-l3 "python $AGENT_L3_BINARY --config-file $Q_CONF_FILE --config-file=$Q_L3_CONF_FILE"
1653
+screen_it q-agt "python $AGENT_BINARY --config-file $QUANTUM_CONF --config-file /$Q_PLUGIN_CONF_FILE"
1654
+screen_it q-dhcp "python $AGENT_DHCP_BINARY --config-file $QUANTUM_CONF --config-file=$Q_DHCP_CONF_FILE"
1655
+screen_it q-meta "python $AGENT_META_BINARY --config-file $QUANTUM_CONF --config-file=$Q_META_CONF_FILE"
1656
+screen_it q-l3 "python $AGENT_L3_BINARY --config-file $QUANTUM_CONF --config-file=$Q_L3_CONF_FILE"
1657 1657
 
1658 1658
 if is_service_enabled nova; then
1659 1659
     echo_summary "Starting Nova"
... ...
@@ -89,8 +89,8 @@ QUANTUM_REPO=${GIT_BASE}/openstack/quantum
89 89
 QUANTUM_BRANCH=master
90 90
 
91 91
 # quantum client
92
-QUANTUM_CLIENT_REPO=${GIT_BASE}/openstack/python-quantumclient
93
-QUANTUM_CLIENT_BRANCH=master
92
+QUANTUMCLIENT_REPO=${GIT_BASE}/openstack/python-quantumclient
93
+QUANTUMCLIENT_BRANCH=master
94 94
 
95 95
 # Tempest test suite
96 96
 TEMPEST_REPO=${GIT_BASE}/openstack/tempest.git