Browse code

Add mechanism to automatically load additional projects

This adds an extras.d directory to contain startup scripts that
stack.sh runs automatically at the end. Similar to local.sh
except the scripts are sourced into the stack.sh process rather
than executed as a child process. This gives them complete
access to the stack.sh environment.

Convert Tempest to use this format as an example.

Change-Id: Ibc95e6aaecf4211da948319eb452293ae4357780

Dean Troyer authored on 2013/01/10 04:42:03
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+# tempest.sh - DevStack extras script
1
+
2
+source $TOP_DIR/lib/tempest
3
+
4
+if [[ "$1" == "stack" ]]; then
5
+    # Configure Tempest last to ensure that the runtime configuration of
6
+    # the various OpenStack services can be queried.
7
+    if is_service_enabled tempest; then
8
+        echo_summary "Configuring Tempest"
9
+        install_tempest
10
+        configure_tempest
11
+    fi
12
+fi
13
+
14
+if [[ "$1" == "unstack" ]]; then
15
+    # no-op
16
+    :
17
+fi
18
+
19
+
0 20
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+The extras.d directory contains project initialization scripts to be
1
+sourced by stack.sh at the end of its run.  This is expected to be
2
+used by external projects that want to be configured, started and
3
+stopped with DevStack.
4
+
5
+Order is controlled by prefixing the script names with the a two digit
6
+sequence number.  Script names must end with '.sh'.  This provides a
7
+convenient way to disable scripts by simoy renaming them.
8
+
9
+DevStack reserves the sequence numbers 00 through 09 and 90 through 99
10
+for its own use.
11
+
12
+The scripts are called with an argument of 'stack' by stack.sh and
13
+with an argument of 'unstack' by unstack.sh.
... ...
@@ -321,7 +321,6 @@ source $TOP_DIR/lib/swift
321 321
 source $TOP_DIR/lib/ceilometer
322 322
 source $TOP_DIR/lib/heat
323 323
 source $TOP_DIR/lib/quantum
324
-source $TOP_DIR/lib/tempest
325 324
 source $TOP_DIR/lib/baremetal
326 325
 
327 326
 # Set the destination directories for OpenStack projects
... ...
@@ -775,9 +774,6 @@ fi
775 775
 if is_service_enabled ceilometer; then
776 776
     install_ceilometer
777 777
 fi
778
-if is_service_enabled tempest; then
779
-    install_tempest
780
-fi
781 778
 
782 779
 
783 780
 # Initialization
... ...
@@ -1314,16 +1310,6 @@ if is_service_enabled nova && is_baremetal; then
1314 1314
     screen_it baremetal "nova-baremetal-deploy-helper"
1315 1315
 fi
1316 1316
 
1317
-# Configure Tempest last to ensure that the runtime configuration of
1318
-# the various OpenStack services can be queried.
1319
-if is_service_enabled tempest; then
1320
-    echo_summary "Configuring Tempest"
1321
-    configure_tempest
1322
-    echo '**************************************************'
1323
-    echo_summary "Finished Configuring Tempest"
1324
-    echo '**************************************************'
1325
-fi
1326
-
1327 1317
 # Save some values we generated for later use
1328 1318
 CURRENT_RUN_TIME=$(date "+$TIMESTAMP_FORMAT")
1329 1319
 echo "# $CURRENT_RUN_TIME" >$TOP_DIR/.stackenv
... ...
@@ -1333,6 +1319,16 @@ for i in BASE_SQL_CONN ENABLED_SERVICES HOST_IP LOGFILE \
1333 1333
 done
1334 1334
 
1335 1335
 
1336
+# Run extras
1337
+# ==========
1338
+
1339
+if [[ -d $TOP_DIR/extras.d ]]; then
1340
+    for i in $TOP_DIR/extras.d/*.sh; do
1341
+        [[ -r $i ]] && source $i stack
1342
+    done
1343
+fi
1344
+
1345
+
1336 1346
 # Run local script
1337 1347
 # ================
1338 1348
 
... ...
@@ -39,6 +39,15 @@ if [[ "$1" == "--all" ]]; then
39 39
     UNSTACK_ALL=${UNSTACK_ALL:-1}
40 40
 fi
41 41
 
42
+# Run extras
43
+# ==========
44
+
45
+if [[ -d $TOP_DIR/extras.d ]]; then
46
+    for i in $TOP_DIR/extras.d/*.sh; do
47
+        [[ -r $i ]] && source $i unstack
48
+    done
49
+fi
50
+
42 51
 if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then
43 52
     source $TOP_DIR/openrc
44 53
     teardown_quantum_debug