Merge "Add stack phases to extras.d handling"
diff --git a/README.md b/README.md
index 66e36b2..514786c 100644
--- a/README.md
+++ b/README.md
@@ -215,6 +215,10 @@
$ cd /opt/stack/tempest
$ nosetests tempest/scenario/test_network_basic_ops.py
+# Additional Projects
+
+DevStack has a hook mechanism to call out to a dispatch script at specific points in the execution if `stack.sh`, `unstack.sh` and `clean.sh`. This allows higher-level projects, especially those that the lower level projects have no dependency on, to be added to DevStack without modifying the scripts. Tempest is built this way as an example of how to structure the dispatch script, see `extras.d/80-tempest.sh`. See `extras.d/README.md` for more information.
+
# Multi-Node Setup
A more interesting setup involves running multiple compute nodes, with Neutron networks connecting VMs on different compute nodes.
diff --git a/clean.sh b/clean.sh
index 6ceb5a4..395941a 100755
--- a/clean.sh
+++ b/clean.sh
@@ -47,6 +47,15 @@
source $TOP_DIR/lib/baremetal
source $TOP_DIR/lib/ldap
+# Extras Source
+# --------------
+
+# Phase: source
+if [[ -d $TOP_DIR/extras.d ]]; then
+ for i in $TOP_DIR/extras.d/*.sh; do
+ [[ -r $i ]] && source $i source
+ done
+fi
# See if there is anything running...
# need to adapt when run_service is merged
@@ -56,6 +65,16 @@
$TOP_DIR/unstack.sh --all
fi
+# Run extras
+# ==========
+
+# Phase: clean
+if [[ -d $TOP_DIR/extras.d ]]; then
+ for i in $TOP_DIR/extras.d/*.sh; do
+ [[ -r $i ]] && source $i clean
+ done
+fi
+
# Clean projects
cleanup_oslo
cleanup_cinder
diff --git a/extras.d/80-tempest.sh b/extras.d/80-tempest.sh
index f159955..75b702c 100644
--- a/extras.d/80-tempest.sh
+++ b/extras.d/80-tempest.sh
@@ -1,21 +1,29 @@
# tempest.sh - DevStack extras script
-source $TOP_DIR/lib/tempest
-
-if [[ "$1" == "stack" ]]; then
- # Configure Tempest last to ensure that the runtime configuration of
- # the various OpenStack services can be queried.
- if is_service_enabled tempest; then
- echo_summary "Configuring Tempest"
+if is_service_enabled tempest; then
+ if [[ "$1" == "source" ]]; then
+ # Initial source
+ source $TOP_DIR/lib/tempest
+ elif [[ "$1" == "stack" && "$2" == "install" ]]; then
+ echo_summary "Installing Tempest"
install_tempest
+ elif [[ "$1" == "stack" && "$2" == "post-config" ]]; then
+ # Tempest config must come after layer 2 services are running
+ :
+ elif [[ "$1" == "stack" && "$2" == "extra" ]]; then
+ echo_summary "Initializing Tempest"
configure_tempest
init_tempest
fi
-fi
-if [[ "$1" == "unstack" ]]; then
- # no-op
- :
-fi
+ if [[ "$1" == "unstack" ]]; then
+ # no-op
+ :
+ fi
+ if [[ "$1" == "clean" ]]; then
+ # no-op
+ :
+ fi
+fi
diff --git a/extras.d/README b/extras.d/README
deleted file mode 100644
index ffc6793..0000000
--- a/extras.d/README
+++ /dev/null
@@ -1,14 +0,0 @@
-The extras.d directory contains project initialization scripts to be
-sourced by stack.sh at the end of its run. This is expected to be
-used by external projects that want to be configured, started and
-stopped with DevStack.
-
-Order is controlled by prefixing the script names with the a two digit
-sequence number. Script names must end with '.sh'. This provides a
-convenient way to disable scripts by simoy renaming them.
-
-DevStack reserves the sequence numbers 00 through 09 and 90 through 99
-for its own use.
-
-The scripts are called with an argument of 'stack' by stack.sh and
-with an argument of 'unstack' by unstack.sh.
diff --git a/extras.d/README.md b/extras.d/README.md
new file mode 100644
index 0000000..591e438
--- /dev/null
+++ b/extras.d/README.md
@@ -0,0 +1,31 @@
+# Extras Hooks
+
+The `extras.d` directory contains project dispatch scripts that are called
+at specific times by `stack.sh`, `unstack.sh` and `clean.sh`. These hooks are
+used to install, configure and start additional projects during a DevStack run
+without any modifications to the base DevStack scripts.
+
+When `stack.sh` reaches one of the hook points it sources the scripts in `extras.d`
+that end with `.sh`. To control the order that the scripts are sourced their
+names start with a two digit sequence number. DevStack reserves the sequence
+numbers 00 through 09 and 90 through 99 for its own use.
+
+The scripts are sourced at each hook point so they should not declare anything
+at the top level that would cause a problem, specifically, functions. This does
+allow the entire `stack.sh` variable space to be available. The scripts are
+sourced with one or more arguments, the first of which defines the hook phase:
+
+arg 1: source | stack | unstack | clean
+
+ source: always called first in any of the scripts, used to set the
+ initial defaults in a lib/* script or similar
+
+ stack: called by stack.sh. There are three possible values for
+ the second arg to distinguish the phase stack.sh is in:
+
+ arg 2: install | post-config | extra
+
+ unstack: called by unstack.sh
+
+ clean: called by clean.sh. Remember, clean.sh also calls unstack.sh
+ so that work need not be repeated.
diff --git a/stack.sh b/stack.sh
index 14ec023..aa0efea 100755
--- a/stack.sh
+++ b/stack.sh
@@ -313,6 +313,16 @@
source $TOP_DIR/lib/ironic
source $TOP_DIR/lib/trove
+# Extras Source
+# --------------
+
+# Phase: source
+if [[ -d $TOP_DIR/extras.d ]]; then
+ for i in $TOP_DIR/extras.d/*.sh; do
+ [[ -r $i ]] && source $i source
+ done
+fi
+
# Set the destination directories for other OpenStack projects
OPENSTACKCLIENT_DIR=$DEST/python-openstackclient
@@ -725,6 +735,16 @@
configure_ironic
fi
+# Extras Install
+# --------------
+
+# Phase: install
+if [[ -d $TOP_DIR/extras.d ]]; then
+ for i in $TOP_DIR/extras.d/*.sh; do
+ [[ -r $i ]] && source $i stack install
+ done
+fi
+
if [[ $TRACK_DEPENDS = True ]]; then
$DEST/.venv/bin/pip freeze > $DEST/requires-post-pip
if ! diff -Nru $DEST/requires-pre-pip $DEST/requires-post-pip > $DEST/requires.diff; then
@@ -1000,6 +1020,17 @@
fi
+# Extras Configuration
+# ====================
+
+# Phase: post-config
+if [[ -d $TOP_DIR/extras.d ]]; then
+ for i in $TOP_DIR/extras.d/*.sh; do
+ [[ -r $i ]] && source $i stack post-config
+ done
+fi
+
+
# Local Configuration
# ===================
@@ -1214,9 +1245,10 @@
# Run extras
# ==========
+# Phase: extra
if [[ -d $TOP_DIR/extras.d ]]; then
for i in $TOP_DIR/extras.d/*.sh; do
- [[ -r $i ]] && source $i stack
+ [[ -r $i ]] && source $i stack extra
done
fi
diff --git a/unstack.sh b/unstack.sh
index c944ccc..67c8b7c 100755
--- a/unstack.sh
+++ b/unstack.sh
@@ -42,6 +42,16 @@
source $TOP_DIR/lib/ironic
source $TOP_DIR/lib/trove
+# Extras Source
+# --------------
+
+# Phase: source
+if [[ -d $TOP_DIR/extras.d ]]; then
+ for i in $TOP_DIR/extras.d/*.sh; do
+ [[ -r $i ]] && source $i source
+ done
+fi
+
# Determine what system we are running on. This provides ``os_VENDOR``,
# ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
GetOSVersion
@@ -53,6 +63,7 @@
# Run extras
# ==========
+# Phase: unstack
if [[ -d $TOP_DIR/extras.d ]]; then
for i in $TOP_DIR/extras.d/*.sh; do
[[ -r $i ]] && source $i unstack