diff --git a/HACKING.rst b/HACKING.rst index d91d4969bd..a105a66e9a 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -43,15 +43,14 @@ Many scripts will utilize shared functions from the ``functions`` file. There a also rc files (``stackrc`` and ``openrc``) that are often included to set the primary configuration of the user environment:: - # Use openrc + stackrc + localrc for settings - pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null + # Keep track of the current devstack directory. + TOP_DIR=$(cd $(dirname "$0") && pwd) # Import common functions - source ./functions + source $TOP_DIR/functions # Import configuration - source ./openrc - popd >/dev/null + source $TOP_DIR/openrc ``stack.sh`` is a rather large monolithic script that flows through from beginning to end. There is a proposal to segment it to put the OpenStack projects @@ -119,6 +118,12 @@ These scripts are executed serially by ``exercise.sh`` in testing situations. # an error. It is also useful for following allowing as the install occurs. set -o xtrace +* Settings and configuration are stored in ``exerciserc``, which must be + sourced after ``openrc`` or ``stackrc``:: + + # Import exercise configuration + source $TOP_DIR/exerciserc + * There are a couple of helper functions in the common ``functions`` sub-script that will check for non-zero exit codes and unset environment variables and print a message and exit the script. These should be called after most client diff --git a/exerciserc b/exerciserc new file mode 100644 index 0000000000..b41714da49 --- /dev/null +++ b/exerciserc @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# source exerciserc +# +# Configure the DevStack exercise scripts +# For best results, source this _after_ stackrc/localrc as it will set +# values only if they are not already set. + +# Max time to wait while vm goes from build to active state +export ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30} + +# Max time to wait for proper IP association and dis-association. +export ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-15} + +# Max time till the vm is bootable +export BOOT_TIMEOUT=${BOOT_TIMEOUT:-30} + +# Max time from run instance command until it is running +export RUNNING_TIMEOUT=${RUNNING_TIMEOUT:-$(($BOOT_TIMEOUT + $ACTIVE_TIMEOUT))} + +# Max time to wait for a vm to terminate +export TERMINATE_TIMEOUT=${TERMINATE_TIMEOUT:-30} diff --git a/exercises/bundle.sh b/exercises/bundle.sh index 47bacac3ae..0f128af1e2 100755 --- a/exercises/bundle.sh +++ b/exercises/bundle.sh @@ -28,6 +28,9 @@ source $TOP_DIR/functions # Import EC2 configuration source $TOP_DIR/eucarc +# Import exercise configuration +source $TOP_DIR/exerciserc + # Remove old certificates rm -f $TOP_DIR/cacert.pem rm -f $TOP_DIR/cert.pem diff --git a/exercises/client-env.sh b/exercises/client-env.sh index d4ba702e05..0f172750e8 100755 --- a/exercises/client-env.sh +++ b/exercises/client-env.sh @@ -22,6 +22,9 @@ source $TOP_DIR/functions # Import configuration source $TOP_DIR/openrc +# Import exercise configuration +source $TOP_DIR/exerciserc + # Unset all of the known NOVA_ vars unset NOVA_API_KEY unset NOVA_ENDPOINT_NAME diff --git a/exercises/euca.sh b/exercises/euca.sh index 2be2f62677..703c7aacdb 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -28,14 +28,8 @@ source $TOP_DIR/functions # Import EC2 configuration source $TOP_DIR/eucarc -# Max time to wait while vm goes from build to active state -ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30} - -# Max time till the vm is bootable -BOOT_TIMEOUT=${BOOT_TIMEOUT:-30} - -# Max time to wait for proper association and dis-association. -ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-15} +# Import exercise configuration +source $TOP_DIR/exerciserc # Instance type to create DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny} diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh index a47f1ffc23..f2b9d0362f 100755 --- a/exercises/floating_ips.sh +++ b/exercises/floating_ips.sh @@ -23,24 +23,18 @@ set -o xtrace # Settings # ======== -# Use openrc + stackrc + localrc for settings -pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null +# Keep track of the current directory +EXERCISE_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) # Import common functions -source ./functions +source $TOP_DIR/functions # Import configuration -source ./openrc -popd >/dev/null +source $TOP_DIR/openrc -# Max time to wait while vm goes from build to active state -ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30} - -# Max time till the vm is bootable -BOOT_TIMEOUT=${BOOT_TIMEOUT:-30} - -# Max time to wait for proper association and dis-association. -ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-15} +# Import exercise configuration +source $TOP_DIR/exerciserc # Instance type to create DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny} diff --git a/exercises/swift.sh b/exercises/swift.sh index 76096379a4..b70b85f268 100755 --- a/exercises/swift.sh +++ b/exercises/swift.sh @@ -18,15 +18,18 @@ set -o xtrace # Settings # ======== -# Use openrc + stackrc + localrc for settings -pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null +# Keep track of the current directory +EXERCISE_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) # Import common functions -source ./functions +source $TOP_DIR/functions # Import configuration -source ./openrc -popd >/dev/null +source $TOP_DIR/openrc + +# Import exercise configuration +source $TOP_DIR/exerciserc # Container name CONTAINER=ex-swift diff --git a/exercises/volumes.sh b/exercises/volumes.sh index a812401a09..77c3498c0c 100755 --- a/exercises/volumes.sh +++ b/exercises/volumes.sh @@ -18,24 +18,18 @@ set -o xtrace # Settings # ======== -# Use openrc + stackrc + localrc for settings -pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null +# Keep track of the current directory +EXERCISE_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) # Import common functions -source ./functions +source $TOP_DIR/functions # Import configuration -source ./openrc -popd >/dev/null +source $TOP_DIR/openrc -# Max time to wait while vm goes from build to active state -ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30} - -# Max time till the vm is bootable -BOOT_TIMEOUT=${BOOT_TIMEOUT:-30} - -# Max time to wait for proper association and dis-association. -ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-15} +# Import exercise configuration +source $TOP_DIR/exerciserc # Instance type to create DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny} diff --git a/openrc b/openrc index 188ffc56d4..7aefb0ffd3 100644 --- a/openrc +++ b/openrc @@ -65,18 +65,3 @@ export COMPUTE_API_VERSION=${COMPUTE_API_VERSION:-$NOVA_VERSION} # set log level to DEBUG (helps debug issues) # export KEYSTONECLIENT_DEBUG=1 # export NOVACLIENT_DEBUG=1 - -# Max time till the vm is bootable -export BOOT_TIMEOUT=${BOOT_TIMEOUT:-30} - -# Max time to wait while vm goes from build to active state -export ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30} - -# Max time from run instance command until it is running -export RUNNING_TIMEOUT=${RUNNING_TIMEOUT:-$(($BOOT_TIMEOUT + $ACTIVE_TIMEOUT))} - -# Max time to wait for proper IP association and dis-association. -export ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-15} - -# Max time to wait for a vm to terminate -export TERMINATE_TIMEOUT=${TERMINATE_TIMEOUT:-30}