75bbd75d |
#!/usr/bin/env bash
# we will use the ``euca2ools`` cli tool that wraps the python boto
# library to test ec2 compatibility |
489bd2a6 |
echo "**************************************************"
echo "Begin DevStack Exercise: $0"
echo "**************************************************" |
75bbd75d |
# 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
# ========
|
0bd2410d |
# Keep track of the current directory
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) |
489bd2a6 |
# Import common functions |
0bd2410d |
source $TOP_DIR/functions |
489bd2a6 |
|
0bd2410d |
# Import EC2 configuration
source $TOP_DIR/eucarc |
75bbd75d |
# Remove old certificates |
0bd2410d |
rm -f $TOP_DIR/cacert.pem
rm -f $TOP_DIR/cert.pem
rm -f $TOP_DIR/pk.pem |
75bbd75d |
# Get Certificates |
0bd2410d |
nova x509-get-root-cert $TOP_DIR/cacert.pem
nova x509-create-cert $TOP_DIR/pk.pem $TOP_DIR/cert.pem |
75bbd75d |
# Max time to wait for image to be registered
REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15}
BUCKET=testbucket
IMAGE=bundle.img
truncate -s 5M /tmp/$IMAGE
euca-bundle-image -i /tmp/$IMAGE |
489bd2a6 |
die_if_error "Failure bundling image $IMAGE" |
75bbd75d |
euca-upload-bundle -b $BUCKET -m /tmp/$IMAGE.manifest.xml |
489bd2a6 |
die_if_error "Failure uploading bundle $IMAGE to $BUCKET"
|
75bbd75d |
AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2` |
489bd2a6 |
die_if_not_set AMI "Failure registering $BUCKET/$IMAGE" |
75bbd75d |
# 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
echo "Image $AMI not available within $REGISTER_TIMEOUT seconds"
exit 1
fi |
80756ea7 |
# Clean up
euca-deregister $AMI |
489bd2a6 |
die_if_error "Failure deregistering $AMI"
set +o xtrace
echo "**************************************************"
echo "End DevStack Exercise: $0"
echo "**************************************************" |