Merge "Allow people to specifiy the XENAPI_CONNECTION_URL"
diff --git a/exercises/bundle.sh b/exercises/bundle.sh
index d5c78af..e1c949c 100755
--- a/exercises/bundle.sh
+++ b/exercises/bundle.sh
@@ -2,7 +2,10 @@
# we will use the ``euca2ools`` cli tool that wraps the python boto
# library to test ec2 compatibility
-#
+
+echo "**************************************************"
+echo "Begin DevStack Exercise: $0"
+echo "**************************************************"
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
@@ -16,7 +19,12 @@
# ========
# Use openrc + stackrc + localrc for settings
-pushd $(cd $(dirname "$0")/.. && pwd)
+pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
+
+# Import common functions
+source ./functions
+
+# Import configuration
source ./openrc
# Remove old certificates
@@ -27,7 +35,7 @@
# Get Certificates
nova x509-get-root-cert
nova x509-create-cert
-popd
+popd >/dev/null
# Max time to wait for image to be registered
REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15}
@@ -36,10 +44,14 @@
IMAGE=bundle.img
truncate -s 5M /tmp/$IMAGE
euca-bundle-image -i /tmp/$IMAGE
+die_if_error "Failure bundling image $IMAGE"
euca-upload-bundle -b $BUCKET -m /tmp/$IMAGE.manifest.xml
+die_if_error "Failure uploading bundle $IMAGE to $BUCKET"
+
AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2`
+die_if_not_set AMI "Failure registering $BUCKET/$IMAGE"
# Wait for the image to become available
if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep '$AMI' | grep 'available'; do sleep 1; done"; then
@@ -49,3 +61,9 @@
# Clean up
euca-deregister $AMI
+die_if_error "Failure deregistering $AMI"
+
+set +o xtrace
+echo "**************************************************"
+echo "End DevStack Exercise: $0"
+echo "**************************************************"
diff --git a/exercises/client-env.sh b/exercises/client-env.sh
index a15a5c0..28c4d95 100755
--- a/exercises/client-env.sh
+++ b/exercises/client-env.sh
@@ -2,6 +2,10 @@
# Test OpenStack client enviroment variable handling
+echo "**************************************************"
+echo "Begin DevStack Exercise: $0"
+echo "**************************************************"
+
# Verify client workage
VERIFY=${1:-""}
@@ -10,6 +14,11 @@
# Use openrc + stackrc + localrc for settings
pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
+
+# Import common functions
+source ./functions
+
+# Import configuration
source ./openrc
popd >/dev/null
@@ -23,19 +32,10 @@
unset NOVA_USERNAME
unset NOVA_VERSION
-# Make sure we have the vars we are expecting
-function is_set() {
- local var=\$"$1"
- eval echo $1=$var
- if eval "[ -z $var ]"; then
- return 1
- fi
- return 0
-}
-
for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do
is_set $i
if [[ $? -ne 0 ]]; then
+ echo "$i expected to be set"
ABORT=1
fi
done
@@ -52,14 +52,6 @@
if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
STATUS_KEYSTONE="Skipped"
else
- # We need to run the keystone test as admin since there doesn't
- # seem to be anything to test the cli vars that runs as a user
- # tenant-list should do that, it isn't implemented (yet)
- xOS_TENANT_NAME=$OS_TENANT_NAME
- xOS_USERNAME=$OS_USERNAME
- export OS_USERNAME=admin
- export OS_TENANT_NAME=admin
-
echo -e "\nTest Keystone"
if keystone service-list; then
STATUS_KEYSTONE="Succeeded"
@@ -67,9 +59,6 @@
STATUS_KEYSTONE="Failed"
RETURN=1
fi
-
- OS_TENANT_NAME=$xOS_TENANT_NAME
- OS_USERNAME=$xOS_USERNAME
fi
fi
@@ -139,4 +128,8 @@
report "Glance" $STATUS_GLANCE
report "Swift" $STATUS_SWIFT
+echo "**************************************************"
+echo "End DevStack Exercise: $0"
+echo "**************************************************"
+
exit $RETURN
diff --git a/exercises/euca.sh b/exercises/euca.sh
index 86cd673..b766bab 100755
--- a/exercises/euca.sh
+++ b/exercises/euca.sh
@@ -2,7 +2,10 @@
# we will use the ``euca2ools`` cli tool that wraps the python boto
# library to test ec2 compatibility
-#
+
+echo "**************************************************"
+echo "Begin DevStack Exercise: $0"
+echo "**************************************************"
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
@@ -16,9 +19,14 @@
# ========
# Use openrc + stackrc + localrc for settings
-pushd $(cd $(dirname "$0")/.. && pwd)
+pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
+
+# Import common functions
+source ./functions
+
+# Import configuration
source ./openrc
-popd
+popd >/dev/null
# Max time to wait while vm goes from build to active state
ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30}
@@ -49,6 +57,7 @@
# Launch it
INSTANCE=`euca-run-instances -g $SECGROUP -t $DEFAULT_INSTANCE_TYPE $IMAGE | grep INSTANCE | cut -f2`
+die_if_not_set INSTANCE "Failure launching instance"
# Assure it has booted within a reasonable time
if ! timeout $RUNNING_TIMEOUT sh -c "while ! euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
@@ -58,12 +67,15 @@
# Allocate floating address
FLOATING_IP=`euca-allocate-address | cut -f2`
+die_if_not_set FLOATING_IP "Failure allocating floating IP"
# Associate floating address
euca-associate-address -i $INSTANCE $FLOATING_IP
+die_if_error "Failure associating address $FLOATING_IP to $INSTANCE"
# Authorize pinging
euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
+die_if_error "Failure authorizing rule in $SECGROUP"
# Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
@@ -73,9 +85,11 @@
# Revoke pinging
euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
+die_if_error "Failure revoking rule in $SECGROUP"
# Release floating address
euca-disassociate-address $FLOATING_IP
+die_if_error "Failure disassociating address $FLOATING_IP"
# Wait just a tick for everything above to complete so release doesn't fail
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while euca-describe-addresses | grep $INSTANCE | grep -q $FLOATING_IP; do sleep 1; done"; then
@@ -85,6 +99,7 @@
# Release floating address
euca-release-address $FLOATING_IP
+die_if_error "Failure releasing address $FLOATING_IP"
# Wait just a tick for everything above to complete so terminate doesn't fail
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while euca-describe-addresses | grep -q $FLOATING_IP; do sleep 1; done"; then
@@ -94,6 +109,7 @@
# Terminate instance
euca-terminate-instances $INSTANCE
+die_if_error "Failure terminating instance $INSTANCE"
# Assure it has terminated within a reasonable time
if ! timeout $TERMINATE_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
@@ -103,3 +119,9 @@
# Delete group
euca-delete-group $SECGROUP
+die_if_error "Failure deleting security group $SECGROUP"
+
+set +o xtrace
+echo "**************************************************"
+echo "End DevStack Exercise: $0"
+echo "**************************************************"
diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh
index b559965..a47f1ff 100755
--- a/exercises/floating_ips.sh
+++ b/exercises/floating_ips.sh
@@ -7,6 +7,10 @@
#
+echo "**************************************************"
+echo "Begin DevStack Exercise: $0"
+echo "**************************************************"
+
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
@@ -20,9 +24,14 @@
# ========
# Use openrc + stackrc + localrc for settings
-pushd $(cd $(dirname "$0")/.. && pwd)
+pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
+
+# Import common functions
+source ./functions
+
+# Import configuration
source ./openrc
-popd
+popd >/dev/null
# Max time to wait while vm goes from build to active state
ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30}
@@ -87,15 +96,16 @@
# List of instance types:
nova flavor-list
-INSTANCE_TYPE=`nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | cut -d"|" -f2`
+INSTANCE_TYPE=`nova flavor-list | grep $DEFAULT_INSTANCE_TYPE | get_field 1`
if [[ -z "$INSTANCE_TYPE" ]]; then
# grab the first flavor in the list to launch if default doesn't exist
- INSTANCE_TYPE=`nova flavor-list | head -n 4 | tail -n 1 | cut -d"|" -f2`
+ INSTANCE_TYPE=`nova flavor-list | head -n 4 | tail -n 1 | get_field 1`
fi
-NAME="myserver"
+NAME="ex-float"
-VM_UUID=`nova boot --flavor $INSTANCE_TYPE --image $IMAGE $NAME --security_groups=$SECGROUP | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
+VM_UUID=`nova boot --flavor $INSTANCE_TYPE --image $IMAGE $NAME --security_groups=$SECGROUP | grep ' id ' | get_field 2`
+die_if_not_set VM_UUID "Failure launching $NAME"
# Testing
# =======
@@ -114,7 +124,8 @@
fi
# get the IP of the server
-IP=`nova show $VM_UUID | grep "private network" | cut -d"|" -f3`
+IP=`nova show $VM_UUID | grep "private network" | get_field 2`
+die_if_not_set IP "Failure retrieving IP address"
# for single node deployments, we can ping private ips
MULTI_HOST=${MULTI_HOST:-0}
@@ -147,7 +158,8 @@
nova secgroup-list-rules $SECGROUP
# allocate a floating ip from default pool
-FLOATING_IP=`nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | cut -d '|' -f2`
+FLOATING_IP=`nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | get_field 1`
+die_if_not_set FLOATING_IP "Failure creating floating IP"
# list floating addresses
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep -q $FLOATING_IP; do sleep 1; done"; then
@@ -157,6 +169,7 @@
# add floating ip to our server
nova add-floating-ip $VM_UUID $FLOATING_IP
+die_if_error "Failure adding floating IP $FLOATING_IP to $NAME"
# test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
@@ -165,7 +178,8 @@
fi
# Allocate an IP from second floating pool
-TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | cut -d '|' -f2`
+TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1`
+die_if_not_set TEST_FLOATING_IP "Failure creating floating IP in $TEST_FLOATING_POOL"
# list floating addresses
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep $TEST_FLOATING_POOL | grep -q $TEST_FLOATING_IP; do sleep 1; done"; then
@@ -175,6 +189,7 @@
# dis-allow icmp traffic (ping)
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0
+die_if_error "Failure deleting security group rule from $SECGROUP"
# FIXME (anthony): make xs support security groups
if [ "$VIRT_DRIVER" != "xenserver" ]; then
@@ -188,12 +203,15 @@
# de-allocate the floating ip
nova floating-ip-delete $FLOATING_IP
+die_if_error "Failure deleting floating IP $FLOATING_IP"
# Delete second floating IP
nova floating-ip-delete $TEST_FLOATING_IP
+die_if_error "Failure deleting floating IP $TEST_FLOATING_IP"
# shutdown the server
nova delete $VM_UUID
+die_if_error "Failure deleting instance $NAME"
# make sure the VM shuts down within a reasonable time
if ! timeout $TERMINATE_TIMEOUT sh -c "while nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
@@ -203,3 +221,9 @@
# Delete a secgroup
nova secgroup-delete $SECGROUP
+die_if_error "Failure deleting security group $SECGROUP"
+
+set +o xtrace
+echo "**************************************************"
+echo "End DevStack Exercise: $0"
+echo "**************************************************"
diff --git a/exercises/swift.sh b/exercises/swift.sh
index 95443df..7609637 100755
--- a/exercises/swift.sh
+++ b/exercises/swift.sh
@@ -2,6 +2,10 @@
# Test swift via the command line tools that ship with it.
+echo "**************************************************"
+echo "Begin DevStack Exercise: $0"
+echo "**************************************************"
+
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
@@ -15,9 +19,17 @@
# ========
# Use openrc + stackrc + localrc for settings
-pushd $(cd $(dirname "$0")/.. && pwd)
+pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
+
+# Import common functions
+source ./functions
+
+# Import configuration
source ./openrc
-popd
+popd >/dev/null
+
+# Container name
+CONTAINER=ex-swift
# Testing Swift
@@ -25,16 +37,26 @@
# Check if we have to swift via keystone
swift stat
+die_if_error "Failure geting status"
# We start by creating a test container
-swift post testcontainer
+swift post $CONTAINER
+die_if_error "Failure creating container $CONTAINER"
# add some files into it.
-swift upload testcontainer /etc/issue
+swift upload $CONTAINER /etc/issue
+die_if_error "Failure uploading file to container $CONTAINER"
# list them
-swift list testcontainer
+swift list $CONTAINER
+die_if_error "Failure listing contents of container $CONTAINER"
# And we may want to delete them now that we have tested that
# everything works.
-swift delete testcontainer
+swift delete $CONTAINER
+die_if_error "Failure deleting container $CONTAINER"
+
+set +o xtrace
+echo "**************************************************"
+echo "End DevStack Exercise: $0"
+echo "**************************************************"
diff --git a/exercises/volumes.sh b/exercises/volumes.sh
index 622fb18..a812401 100755
--- a/exercises/volumes.sh
+++ b/exercises/volumes.sh
@@ -2,6 +2,10 @@
# Test nova volumes with the nova command from python-novaclient
+echo "**************************************************"
+echo "Begin DevStack Exercise: $0"
+echo "**************************************************"
+
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
@@ -15,9 +19,14 @@
# ========
# Use openrc + stackrc + localrc for settings
-pushd $(cd $(dirname "$0")/.. && pwd)
+pushd $(cd $(dirname "$0")/.. && pwd) >/dev/null
+
+# Import common functions
+source ./functions
+
+# Import configuration
source ./openrc
-popd
+popd >/dev/null
# Max time to wait while vm goes from build to active state
ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30}
@@ -55,21 +64,6 @@
# determinine instance type
# -------------------------
-# Helper function to grab a numbered field from python novaclient cli result
-# Fields are numbered starting with 1
-# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.
-function get_field () {
- while read data
- do
- if [ "$1" -lt 0 ]; then
- field="(\$(NF$1))"
- else
- field="\$$(($1 + 1))"
- fi
- echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}"
- done
-}
-
# List of instance types:
nova flavor-list
@@ -79,9 +73,11 @@
INSTANCE_TYPE=`nova flavor-list | head -n 4 | tail -n 1 | get_field 1`
fi
-NAME="myserver"
+NAME="ex-vol"
VM_UUID=`nova boot --flavor $INSTANCE_TYPE --image $IMAGE $NAME --security_groups=$SECGROUP | grep ' id ' | get_field 2`
+die_if_not_set VM_UUID "Failure launching $NAME"
+
# Testing
# =======
@@ -101,6 +97,7 @@
# get the IP of the server
IP=`nova show $VM_UUID | grep "private network" | get_field 2`
+die_if_not_set IP "Failure retrieving IP address"
# for single node deployments, we can ping private ips
MULTI_HOST=${MULTI_HOST:-0}
@@ -130,6 +127,10 @@
# Create a new volume
nova volume-create --display_name $VOL_NAME --display_description "test volume: $VOL_NAME" 1
+if [[ $? != 0 ]]; then
+ echo "Failure creating volume $VOL_NAME"
+ exit 1
+fi
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME | grep available; do sleep 1; done"; then
echo "Volume $VOL_NAME not created"
exit 1
@@ -137,16 +138,19 @@
# Get volume ID
VOL_ID=`nova volume-list | grep $VOL_NAME | head -1 | get_field 1`
+die_if_not_set VOL_ID "Failure retrieving volume ID for $VOL_NAME"
# Attach to server
DEVICE=/dev/vdb
nova volume-attach $VM_UUID $VOL_ID $DEVICE
+die_if_error "Failure attaching volume $VOL_NAME to $NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME | grep in-use; do sleep 1; done"; then
echo "Volume $VOL_NAME not attached to $NAME"
exit 1
fi
VOL_ATTACH=`nova volume-list | grep $VOL_NAME | head -1 | get_field -1`
+die_if_not_set VOL_ATTACH "Failure retrieving $VOL_NAME status"
if [[ "$VOL_ATTACH" != $VM_UUID ]]; then
echo "Volume not attached to correct instance"
exit 1
@@ -154,6 +158,7 @@
# Detach volume
nova volume-detach $VM_UUID $VOL_ID
+die_if_error "Failure detaching volume $VOL_NAME from $NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME | grep available; do sleep 1; done"; then
echo "Volume $VOL_NAME not detached from $NAME"
exit 1
@@ -161,6 +166,7 @@
# Delete volume
nova volume-delete $VOL_ID
+die_if_error "Failure deleting volume $VOL_NAME"
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $VOL_NAME; do sleep 1; done"; then
echo "Volume $VOL_NAME not deleted"
exit 1
@@ -168,3 +174,9 @@
# shutdown the server
nova delete $NAME
+die_if_error "Failure deleting instance $NAME"
+
+set +o xtrace
+echo "**************************************************"
+echo "End DevStack Exercise: $0"
+echo "**************************************************"
diff --git a/functions b/functions
index 01c4758..adcf5bd 100644
--- a/functions
+++ b/functions
@@ -22,6 +22,48 @@
}
+# Checks the exit code of the last command and prints "message"
+# if it is non-zero and exits
+# die_if_error "message"
+function die_if_error() {
+ local exitcode=$?
+ if [ $exitcode != 0 ]; then
+ echo $@
+ exit $exitcode
+ fi
+}
+
+
+# Checks an environment variable is not set or has length 0 OR if the
+# exit code is non-zero and prints "message" and exits
+# NOTE: env-var is the variable name without a '$'
+# die_if_not_set env-var "message"
+function die_if_not_set() {
+ local exitcode=$?
+ local evar=$1; shift
+ if ! is_set $evar || [ $exitcode != 0 ]; then
+ echo $@
+ exit 99
+ fi
+}
+
+
+# Grab a numbered field from python prettytable output
+# Fields are numbered starting with 1
+# Reverse syntax is supported: -1 is the last field, -2 is second to last, etc.
+# get_field field-number
+function get_field() {
+ while read data; do
+ if [ "$1" -lt 0 ]; then
+ field="(\$(NF$1))"
+ else
+ field="\$$(($1 + 1))"
+ fi
+ echo "$data" | awk -F'[ \t]*\\|[ \t]*' "{print $field}"
+ done
+}
+
+
# git clone only if directory doesn't exist already. Since ``DEST`` might not
# be owned by the installation user, we create the directory and change the
# ownership to the proper user.
@@ -67,6 +109,18 @@
}
+
+# Test if the named environment variable is set and not zero length
+# is_set env-var
+function is_set() {
+ local var=\$"$1"
+ if eval "[ -z $var ]"; then
+ return 1
+ fi
+ return 0
+}
+
+
# pip install wrapper to set cache and proxy environment variables
# pip_install package [package ...]
function pip_install {
diff --git a/openrc b/openrc
index 9b3d7ba..d9e7c92 100644
--- a/openrc
+++ b/openrc
@@ -1,8 +1,40 @@
#!/usr/bin/env bash
+#
+# source openrc [username] [tenantname]
+#
+# Configure a set of credentials for $TENANT/$USERNAME:
+# Set TENANT to override the default tenant 'demo'
+# Set USERNAME to override the default user name 'demo'
+# Set ADMIN_PASSWORD to set the password for 'admin' and 'demo'
+
+# NOTE: support for the old NOVA_* novaclient environment variables has
+# been removed.
+
+if [[ -n "$1" ]]; then
+ USERNAME=$1
+fi
+if [[ -n "$2" ]]; then
+ TENANT=$2
+fi
# Load local configuration
source ./stackrc
+# The introduction of Keystone to the OpenStack ecosystem has standardized the
+# term **tenant** as the entity that owns resources. In some places references
+# still exist to the original Nova term **project** for this use. Also,
+# **tenant_name** is prefered to **tenant_id**.
+export OS_TENANT_NAME=${TENANT:-demo}
+
+# In addition to the owning entity (tenant), nova stores the entity performing
+# the action as the **user**.
+export OS_USERNAME=${USERNAME:-demo}
+
+# With Keystone you pass the keystone password instead of an api key.
+# Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs
+# or NOVA_PASSWORD.
+export OS_PASSWORD=${ADMIN_PASSWORD:-secrete}
+
# Set api HOST_IP endpoint. SERVICE_HOST may also be used to specify the endpoint,
# which is convenient for some localrc configurations.
HOST_IP=${HOST_IP:-127.0.0.1}
@@ -12,45 +44,20 @@
# should be listening on HOST_IP. If its running elsewhere, it can be set here
GLANCE_HOST=${GLANCE_HOST:-$HOST_IP}
-# novaclient now supports the new OS_* configuration variables in addition to
-# the older NOVA_* variables. Set them both for now...
-
-# Nova original used project_id as the *account* that owned resources (servers,
-# ip address, ...) With the addition of Keystone we have standardized on the
-# term **tenant** as the entity that owns the resources. **novaclient** still
-# uses the old deprecated terms project_id. Note that this field should now be
-# set to tenant_name, not tenant_id.
-export NOVA_PROJECT_ID=${TENANT:-demo}
-export OS_TENANT_NAME=${NOVA_PROJECT_ID}
-
-# In addition to the owning entity (tenant), nova stores the entity performing
-# the action as the **user**.
-export NOVA_USERNAME=${USERNAME:-demo}
-export OS_USERNAME=${NOVA_USERNAME}
-
-# With Keystone you pass the keystone password instead of an api key.
-# Recent versions of novaclient use NOVA_PASSWORD instead of NOVA_API_KEY
-# The most recent versions of novaclient use OS_PASSWORD in addition to NOVA_PASSWORD
-export NOVA_PASSWORD=${ADMIN_PASSWORD:-secrete}
-export OS_PASSWORD=${NOVA_PASSWORD}
-
-# With the addition of Keystone, to use an openstack cloud you should
-# authenticate against keystone, which returns a **Token** and **Service
-# Catalog**. The catalog contains the endpoint for all services the user/tenant
-# has access to - including nova, glance, keystone, swift, ... We currently
-# recommend using the 2.0 *auth api*.
+# Authenticating against an Openstack cloud using Keystone returns a **Token**
+# and **Service Catalog**. The catalog contains the endpoints for all services
+# the user/tenant has access to - including nova, glance, keystone, swift, ...
+# We currently recommend using the 2.0 *identity api*.
#
-# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We
+# *NOTE*: Using the 2.0 *identity api* does not mean that compute api is 2.0. We
# will use the 1.1 *compute api*
-export NOVA_URL=${NOVA_URL:-http://$SERVICE_HOST:5000/v2.0}
-export OS_AUTH_URL=${NOVA_URL}
+export OS_AUTH_URL=http://$SERVICE_HOST:5000/v2.0
# Currently novaclient needs you to specify the *compute api* version. This
# needs to match the config of your catalog returned by Keystone.
export NOVA_VERSION=${NOVA_VERSION:-1.1}
-
-# FIXME - why does this need to be specified?
-export NOVA_REGION_NAME=${NOVA_REGION_NAME:-RegionOne}
+# In the future this will change names:
+export COMPUTE_API_VERSION=${COMPUTE_API_VERSION:-$NOVA_VERSION}
# Set the ec2 url so euca2ools works
export EC2_URL=${EC2_URL:-http://$SERVICE_HOST:8773/services/Cloud}
diff --git a/stack.sh b/stack.sh
index 3e59b61..6bbf302 100755
--- a/stack.sh
+++ b/stack.sh
@@ -290,14 +290,26 @@
# FIXME: more documentation about why these are important flags. Also
# we should make sure we use the same variable names as the flag names.
+if [ "$VIRT_DRIVER" = 'xenserver' ]; then
+ PUBLIC_INTERFACE_DEFAULT=eth3
+ # allow build_domU.sh to specify the flat network bridge via kernel args
+ FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[^.]*' /proc/cmdline | cut -d= -f 2)
+ GUEST_INTERFACE_DEFAULT=eth1
+else
+ PUBLIC_INTERFACE_DEFAULT=br100
+ FLAT_NETWORK_BRIDGE_DEFAULT=br100
+ GUEST_INTERFACE_DEFAULT=eth0
+fi
+
+PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-$PUBLIC_INTERFACE_DEFAULT}
PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-br100}
FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28}
NET_MAN=${NET_MAN:-FlatDHCPManager}
EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST}
-FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
-VLAN_INTERFACE=${VLAN_INTERFACE:-eth0}
+FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-$FLAT_NETWORK_BRIDGE_DEFAULT}
+VLAN_INTERFACE=${VLAN_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
# Test floating pool and range are used for testing. They are defined
# here until the admin APIs can replace nova-manage
@@ -323,7 +335,7 @@
# devices other than that node, you can set the flat interface to the same
# value as ``FLAT_NETWORK_BRIDGE``. This will stop the network hiccup from
# occurring.
-FLAT_INTERFACE=${FLAT_INTERFACE:-eth0}
+FLAT_INTERFACE=${FLAT_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
## FIXME(ja): should/can we check that FLAT_INTERFACE is sane?
@@ -1213,6 +1225,10 @@
add_nova_flag "--my_ip=$HOST_IP"
add_nova_flag "--public_interface=$PUBLIC_INTERFACE"
add_nova_flag "--vlan_interface=$VLAN_INTERFACE"
+add_nova_flag "--flat_network_bridge=$FLAT_NETWORK_BRIDGE"
+if [ -n "$FLAT_INTERFACE" ]; then
+ add_nova_flag "--flat_interface=$FLAT_INTERFACE"
+fi
add_nova_flag "--sql_connection=$BASE_SQL_CONN/nova"
add_nova_flag "--libvirt_type=$LIBVIRT_TYPE"
add_nova_flag "--instance_name_template=${INSTANCE_NAME_PREFIX}%08x"
@@ -1262,8 +1278,6 @@
# ---------
if [ "$VIRT_DRIVER" = 'xenserver' ]; then
- # Get the VM bridge
- FLAT_NETWORK_BRIDGE=$(grep -o 'flat_network_bridge=[^.]*' /proc/cmdline | cut -d= -f 2)
read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
add_nova_flag "--connection_type=xenapi"
XENAPI_CONNECTION_URL=${XENAPI_CONNECTION_URL:-"http://169.254.0.1"}
@@ -1271,9 +1285,6 @@
add_nova_flag "--xenapi_connection_username=root"
add_nova_flag "--xenapi_connection_password=$XENAPI_PASSWORD"
add_nova_flag "--noflat_injected"
- add_nova_flag "--flat_interface=eth1"
- add_nova_flag "--flat_network_bridge=${FLAT_NETWORK_BRIDGE}"
- add_nova_flag "--public_interface=${HOST_IP_IFACE}"
# Need to avoid crash due to new firewall support
XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
add_nova_flag "--firewall_driver=$XEN_FIREWALL_DRIVER"
@@ -1281,10 +1292,6 @@
add_nova_flag "--connection_type=libvirt"
LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"}
add_nova_flag "--firewall_driver=$LIBVIRT_FIREWALL_DRIVER"
- add_nova_flag "--flat_network_bridge=$FLAT_NETWORK_BRIDGE"
- if [ -n "$FLAT_INTERFACE" ]; then
- add_nova_flag "--flat_interface=$FLAT_INTERFACE"
- fi
fi
# Nova Database
@@ -1574,9 +1581,9 @@
fi
tar -zxf $FILES/tty.tgz -C $FILES/images
- RVAL=`glance add -A $TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image`
+ RVAL=`glance add --silent-upload -A $TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image`
KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
- RVAL=`glance add -A $TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image`
+ RVAL=`glance add --silent-upload -A $TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image`
RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
glance add -A $TOKEN name="tty" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID ramdisk_id=$RAMDISK_ID < $FILES/images/ami-tty/image
fi
@@ -1625,11 +1632,11 @@
# kernel for use when uploading the root filesystem.
KERNEL_ID=""; RAMDISK_ID="";
if [ -n "$KERNEL" ]; then
- RVAL=`glance add -A $TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"`
+ RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"`
KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
fi
if [ -n "$RAMDISK" ]; then
- RVAL=`glance add -A $TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"`
+ RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"`
RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
fi
glance add -A $TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat --force "${IMAGE}")
diff --git a/tests/functions.sh b/tests/functions.sh
new file mode 100755
index 0000000..0fd76cc
--- /dev/null
+++ b/tests/functions.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+
+# Tests for DevStack functions
+
+TOP=$(cd $(dirname "$0")/.. && pwd)
+
+# Import common functions
+source $TOP/functions
+
+# Import configuration
+source $TOP/openrc
+
+
+echo "Testing die_if_error()"
+
+bash -c "source $TOP/functions; true; die_if_error 'not OK'"
+if [[ $? != 0 ]]; then
+ echo "die_if_error [true] Failed"
+fi
+
+bash -c "source $TOP/functions; false; die_if_error 'OK'"
+if [[ $? = 0 ]]; then
+ echo "die_if_error [false] Failed"
+else
+ echo 'OK'
+fi
+
+
+echo "Testing die_if_not_set()"
+
+bash -c "source $TOP/functions; X=`echo Y && true`; die_if_not_set X 'not OK'"
+if [[ $? != 0 ]]; then
+ echo "die_if_not_set [X='Y' true] Failed"
+else
+ echo 'OK'
+fi
+
+bash -c "source $TOP/functions; X=`true`; die_if_not_set X 'OK'"
+if [[ $? = 0 ]]; then
+ echo "die_if_not_set [X='' true] Failed"
+fi
+
+bash -c "source $TOP/functions; X=`echo Y && false`; die_if_not_set X 'not OK'"
+if [[ $? != 0 ]]; then
+ echo "die_if_not_set [X='Y' false] Failed"
+else
+ echo 'OK'
+fi
+
+bash -c "source $TOP/functions; X=`false`; die_if_not_set X 'OK'"
+if [[ $? = 0 ]]; then
+ echo "die_if_not_set [X='' false] Failed"
+fi
+