| ... | ... |
@@ -12,7 +12,6 @@ set -o errexit |
| 12 | 12 |
# an error. It is also useful for following allowing as the install occurs. |
| 13 | 13 |
set -o xtrace |
| 14 | 14 |
|
| 15 |
- |
|
| 16 | 15 |
# Settings |
| 17 | 16 |
# ======== |
| 18 | 17 |
|
| ... | ... |
@@ -21,16 +20,52 @@ pushd $(cd $(dirname "$0")/.. && pwd) |
| 21 | 21 |
source ./openrc |
| 22 | 22 |
popd |
| 23 | 23 |
|
| 24 |
-# find a machine image to boot |
|
| 24 |
+# Find a machine image to boot |
|
| 25 | 25 |
IMAGE=`euca-describe-images | grep machine | cut -f2 | head -n1` |
| 26 | 26 |
|
| 27 |
-# launch it |
|
| 28 |
-INSTANCE=`euca-run-instances $IMAGE | grep INSTANCE | cut -f2` |
|
| 27 |
+# Define secgroup |
|
| 28 |
+SECGROUP=euca_secgroup |
|
| 29 |
+ |
|
| 30 |
+# Add a secgroup |
|
| 31 |
+euca-add-group -d description $SECGROUP |
|
| 29 | 32 |
|
| 30 |
-# assure it has booted within a reasonable time |
|
| 33 |
+# Launch it |
|
| 34 |
+INSTANCE=`euca-run-instances -g $SECGROUP -t m1.tiny $IMAGE | grep INSTANCE | cut -f2` |
|
| 35 |
+ |
|
| 36 |
+# Assure it has booted within a reasonable time |
|
| 31 | 37 |
if ! timeout $RUNNING_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then |
| 32 | 38 |
echo "server didn't become active within $RUNNING_TIMEOUT seconds" |
| 33 | 39 |
exit 1 |
| 34 | 40 |
fi |
| 35 | 41 |
|
| 42 |
+# Allocate floating address |
|
| 43 |
+FLOATING_IP=`euca-allocate-address | cut -f2` |
|
| 44 |
+ |
|
| 45 |
+# Release floating address |
|
| 46 |
+euca-associate-address -i $INSTANCE $FLOATING_IP |
|
| 47 |
+ |
|
| 48 |
+ |
|
| 49 |
+# Authorize pinging |
|
| 50 |
+euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP |
|
| 51 |
+ |
|
| 52 |
+# Max time till the vm is bootable |
|
| 53 |
+BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
|
|
| 54 |
+if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then |
|
| 55 |
+ echo "Couldn't ping server" |
|
| 56 |
+ exit 1 |
|
| 57 |
+fi |
|
| 58 |
+ |
|
| 59 |
+# Revoke pinging |
|
| 60 |
+euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP |
|
| 61 |
+ |
|
| 62 |
+# Delete group |
|
| 63 |
+euca-delete-group $SECGROUP |
|
| 64 |
+ |
|
| 65 |
+# Release floating address |
|
| 66 |
+euca-disassociate-address $FLOATING_IP |
|
| 67 |
+ |
|
| 68 |
+# Release floating address |
|
| 69 |
+euca-release-address $FLOATING_IP |
|
| 70 |
+ |
|
| 71 |
+# Terminate instance |
|
| 36 | 72 |
euca-terminate-instances $INSTANCE |