devstack_custom/exercises/euca.sh

37 lines
999 B
Bash
Raw Normal View History

2011-11-01 23:04:14 +00:00
#!/usr/bin/env bash
2011-11-01 23:05:40 +00:00
# we will use the ``euca2ools`` cli tool that wraps the python boto
# library to test ec2 compatibility
2011-11-01 23:04:14 +00:00
#
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# Use openrc + stackrc + localrc for settings
2011-11-01 23:44:19 +00:00
pushd $(cd $(dirname "$0")/.. && pwd)
2011-11-01 23:04:14 +00:00
source ./openrc
2011-11-01 23:44:19 +00:00
popd
2011-11-01 23:04:14 +00:00
2011-11-01 23:05:40 +00:00
# find a machine image to boot
2011-11-01 23:04:14 +00:00
IMAGE=`euca-describe-images | grep machine | cut -f2`
2011-11-01 23:05:40 +00:00
# launch it
INSTANCE=`euca-run-instances $IMAGE | grep INSTANCE | cut -f2`
2011-11-01 23:04:14 +00:00
2011-11-01 23:05:40 +00:00
# assure it has booted within a reasonable time
2011-11-01 23:04:14 +00:00
if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
echo "server didn't become active within $BOOT_TIMEOUT seconds"
exit 1
fi
euca-terminate-instances $INSTANCE