Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame^] | 3 | # we will use the ``euca2ools`` cli tool that wraps the python boto |
| 4 | # library to test ec2 compatibility |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 5 | # |
| 6 | |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 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 | |
| 16 | # Settings |
| 17 | # ======== |
| 18 | |
| 19 | # Use openrc + stackrc + localrc for settings |
| 20 | source ./openrc |
| 21 | |
| 22 | # Max time till the vm is bootable |
| 23 | BOOT_TIMEOUT=${BOOT_TIMEOUT:-15} |
| 24 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame^] | 25 | # find a machine image to boot |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 26 | IMAGE=`euca-describe-images | grep machine | cut -f2` |
| 27 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame^] | 28 | # launch it |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 29 | INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2` |
| 30 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame^] | 31 | # assure it has booted within a reasonable time |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 32 | if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then |
| 33 | echo "server didn't become active within $BOOT_TIMEOUT seconds" |
| 34 | exit 1 |
| 35 | fi |
| 36 | |
| 37 | euca-terminate-instances $INSTANCE |