# DIVIDER #!/usr/bin/env bash # DIVIDER echo "*********************************************************************" echo "Begin DevStack Exercise: $0" echo "*********************************************************************" # DIVIDER set -o errexit # DIVIDER set -o xtrace # DIVIDER # DIVIDER EXERCISE_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) # DIVIDER source $TOP_DIR/functions # DIVIDER source $TOP_DIR/eucarc # DIVIDER source $TOP_DIR/exerciserc # DIVIDER rm -f $TOP_DIR/cacert.pem rm -f $TOP_DIR/cert.pem rm -f $TOP_DIR/pk.pem # DIVIDER is_service_enabled n-api || exit 55 # DIVIDER nova x509-get-root-cert $TOP_DIR/cacert.pem nova x509-create-cert $TOP_DIR/pk.pem $TOP_DIR/cert.pem # DIVIDER REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15} BUCKET=testbucket IMAGE=bundle.img truncate -s 5M /tmp/$IMAGE euca-bundle-image -i /tmp/$IMAGE || die $LINENO "Failure bundling image $IMAGE" euca-upload-bundle --debug -b $BUCKET -m /tmp/$IMAGE.manifest.xml || die $LINENO "Failure uploading bundle $IMAGE to $BUCKET" AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2` die_if_not_set $LINENO AMI "Failure registering $BUCKET/$IMAGE" # DIVIDER if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep $AMI | grep -q available; do sleep 1; done"; then die $LINENO "Image $AMI not available within $REGISTER_TIMEOUT seconds" fi # DIVIDER euca-deregister $AMI || die $LINENO "Failure deregistering $AMI" set +o xtrace echo "*********************************************************************" echo "SUCCESS: End DevStack Exercise: $0" echo "*********************************************************************" # DIVIDER

we will use the euca2ools cli tool that wraps the python boto library to test ec2 bundle upload compatibility

This script exits on an error so that errors don't compound and you see only the first error that occurred.

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.


Keep track of the current directory

Import common functions

Import EC2 configuration

Import exercise configuration

Remove old certificates

If nova api is not enabled we exit with exitcode 55 so that the exercise is skipped

Get Certificates

Max time to wait for image to be registered

Wait for the image to become available

Clean up