| ... | ... |
@@ -1,12 +1,9 @@ |
| 1 | 1 |
#!/usr/bin/env bash |
| 2 | 2 |
|
| 3 |
-# **exercise.sh** - using the cloud can be fun |
|
| 4 |
- |
|
| 5 |
-# we will use the ``nova`` cli tool provided by the ``python-novaclient`` |
|
| 6 |
-# package |
|
| 3 |
+# we will use the ``euca2ools`` cli tool that wraps the python boto |
|
| 4 |
+# library to test ec2 compatibility |
|
| 7 | 5 |
# |
| 8 | 6 |
|
| 9 |
- |
|
| 10 | 7 |
# This script exits on an error so that errors don't compound and you see |
| 11 | 8 |
# only the first error that occured. |
| 12 | 9 |
set -o errexit |
| ... | ... |
@@ -25,10 +22,13 @@ source ./openrc |
| 25 | 25 |
# Max time till the vm is bootable |
| 26 | 26 |
BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
|
| 27 | 27 |
|
| 28 |
+# find a machine image to boot |
|
| 28 | 29 |
IMAGE=`euca-describe-images | grep machine | cut -f2` |
| 29 | 30 |
|
| 31 |
+# launch it |
|
| 30 | 32 |
INSTANCE=`euca-run-instance $IMAGE | grep INSTANCE | cut -f2` |
| 31 | 33 |
|
| 34 |
+# assure it has booted within a reasonable time |
|
| 32 | 35 |
if ! timeout $BOOT_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then |
| 33 | 36 |
echo "server didn't become active within $BOOT_TIMEOUT seconds" |
| 34 | 37 |
exit 1 |