Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 3 | # we will use the ``euca2ools`` cli tool that wraps the python boto |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame] | 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 |
Jesse Andrews | 787af01 | 2011-11-01 16:44:19 -0700 | [diff] [blame] | 20 | pushd $(cd $(dirname "$0")/.. && pwd) |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 21 | source ./openrc |
Jesse Andrews | 787af01 | 2011-11-01 16:44:19 -0700 | [diff] [blame] | 22 | popd |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 23 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame] | 24 | # find a machine image to boot |
Jesse Andrews | 9c7c908 | 2011-11-23 10:10:53 -0800 | [diff] [blame] | 25 | IMAGE=`euca-describe-images | grep machine | cut -f2 | head -n1` |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 26 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame] | 27 | # launch it |
Todd Willey | 9e9132d | 2011-11-04 12:09:54 -0400 | [diff] [blame] | 28 | INSTANCE=`euca-run-instances $IMAGE | grep INSTANCE | cut -f2` |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 29 | |
Jesse Andrews | 9f18634 | 2011-11-01 16:05:40 -0700 | [diff] [blame] | 30 | # assure it has booted within a reasonable time |
Todd Willey | 9a3066f | 2011-11-05 11:02:34 -0400 | [diff] [blame] | 31 | if ! timeout $RUNNING_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then |
| 32 | echo "server didn't become active within $RUNNING_TIMEOUT seconds" |
Jesse Andrews | f670549 | 2011-11-01 16:04:14 -0700 | [diff] [blame] | 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | euca-terminate-instances $INSTANCE |