Vishvananda Ishaya | 75bbd75 | 2012-01-19 23:28:46 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # we will use the ``euca2ools`` cli tool that wraps the python boto |
| 4 | # library to test ec2 compatibility |
| 5 | # |
| 6 | |
| 7 | # This script exits on an error so that errors don't compound and you see |
| 8 | # only the first error that occured. |
| 9 | set -o errexit |
| 10 | |
| 11 | # Print the commands being run so that we can see the command that triggers |
| 12 | # an error. It is also useful for following allowing as the install occurs. |
| 13 | set -o xtrace |
| 14 | |
| 15 | # Settings |
| 16 | # ======== |
| 17 | |
| 18 | # Use openrc + stackrc + localrc for settings |
| 19 | pushd $(cd $(dirname "$0")/.. && pwd) |
| 20 | source ./openrc |
| 21 | |
| 22 | # Remove old certificates |
| 23 | rm -f cacert.pem |
| 24 | rm -f cert.pem |
| 25 | rm -f pk.pem |
| 26 | |
| 27 | # Get Certificates |
| 28 | nova x509-get-root-cert |
| 29 | nova x509-create-cert |
| 30 | popd |
| 31 | |
| 32 | # Max time to wait for image to be registered |
| 33 | REGISTER_TIMEOUT=${REGISTER_TIMEOUT:-15} |
| 34 | |
| 35 | BUCKET=testbucket |
| 36 | IMAGE=bundle.img |
| 37 | truncate -s 5M /tmp/$IMAGE |
| 38 | euca-bundle-image -i /tmp/$IMAGE |
| 39 | |
| 40 | |
| 41 | euca-upload-bundle -b $BUCKET -m /tmp/$IMAGE.manifest.xml |
| 42 | AMI=`euca-register $BUCKET/$IMAGE.manifest.xml | cut -f2` |
| 43 | |
| 44 | # Wait for the image to become available |
| 45 | if ! timeout $REGISTER_TIMEOUT sh -c "while euca-describe-images | grep '$AMI' | grep 'available'; do sleep 1; done"; then |
| 46 | echo "Image $AMI not available within $REGISTER_TIMEOUT seconds" |
| 47 | exit 1 |
| 48 | fi |