From 768295e9f1b0ee74635f8b3002cf7e1971bbdddf Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Wed, 9 Jan 2013 13:42:03 -0600 Subject: [PATCH] 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 --- extras.d/80-tempest.sh | 20 ++++++++++++++++++++ extras.d/README | 14 ++++++++++++++ stack.sh | 24 ++++++++++-------------- unstack.sh | 9 +++++++++ 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 extras.d/80-tempest.sh create mode 100644 extras.d/README diff --git a/extras.d/80-tempest.sh b/extras.d/80-tempest.sh new file mode 100644 index 0000000000..506ccef75d --- /dev/null +++ b/extras.d/80-tempest.sh @@ -0,0 +1,20 @@ +# 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" + install_tempest + configure_tempest + fi +fi + +if [[ "$1" == "unstack" ]]; then + # no-op + : +fi + + diff --git a/extras.d/README b/extras.d/README new file mode 100644 index 0000000000..ffc6793abd --- /dev/null +++ b/extras.d/README @@ -0,0 +1,14 @@ +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/stack.sh b/stack.sh index 9f734b9ef9..533009980c 100755 --- a/stack.sh +++ b/stack.sh @@ -321,7 +321,6 @@ source $TOP_DIR/lib/swift source $TOP_DIR/lib/ceilometer source $TOP_DIR/lib/heat source $TOP_DIR/lib/quantum -source $TOP_DIR/lib/tempest source $TOP_DIR/lib/baremetal # Set the destination directories for OpenStack projects @@ -775,9 +774,6 @@ fi if is_service_enabled ceilometer; then install_ceilometer fi -if is_service_enabled tempest; then - install_tempest -fi # Initialization @@ -1314,16 +1310,6 @@ if is_service_enabled nova && is_baremetal; then screen_it baremetal "nova-baremetal-deploy-helper" fi -# 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" - configure_tempest - echo '**************************************************' - echo_summary "Finished Configuring Tempest" - echo '**************************************************' -fi - # Save some values we generated for later use CURRENT_RUN_TIME=$(date "+$TIMESTAMP_FORMAT") echo "# $CURRENT_RUN_TIME" >$TOP_DIR/.stackenv @@ -1333,6 +1319,16 @@ for i in BASE_SQL_CONN ENABLED_SERVICES HOST_IP LOGFILE \ done +# Run extras +# ========== + +if [[ -d $TOP_DIR/extras.d ]]; then + for i in $TOP_DIR/extras.d/*.sh; do + [[ -r $i ]] && source $i stack + done +fi + + # Run local script # ================ diff --git a/unstack.sh b/unstack.sh index fd70916d91..1d4bfd56f1 100755 --- a/unstack.sh +++ b/unstack.sh @@ -39,6 +39,15 @@ if [[ "$1" == "--all" ]]; then UNSTACK_ALL=${UNSTACK_ALL:-1} fi +# Run extras +# ========== + +if [[ -d $TOP_DIR/extras.d ]]; then + for i in $TOP_DIR/extras.d/*.sh; do + [[ -r $i ]] && source $i unstack + done +fi + if [[ "$Q_USE_DEBUG_COMMAND" == "True" ]]; then source $TOP_DIR/openrc teardown_quantum_debug