Improve euca exercise to use floating ips and secgroups. This ensures that the full instance lifecycle gets 'worked.'
Change-Id: Ibf22054ae3fb864242ff3df2b8066985a43803d7
This commit is contained in:
parent
e0d6cd1e92
commit
abda427a10
@ -12,7 +12,6 @@ set -o errexit
|
|||||||
# an error. It is also useful for following allowing as the install occurs.
|
# an error. It is also useful for following allowing as the install occurs.
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
# ========
|
# ========
|
||||||
|
|
||||||
@ -21,16 +20,52 @@ pushd $(cd $(dirname "$0")/.. && pwd)
|
|||||||
source ./openrc
|
source ./openrc
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# find a machine image to boot
|
# Find a machine image to boot
|
||||||
IMAGE=`euca-describe-images | grep machine | cut -f2 | head -n1`
|
IMAGE=`euca-describe-images | grep machine | cut -f2 | head -n1`
|
||||||
|
|
||||||
# launch it
|
# Define secgroup
|
||||||
INSTANCE=`euca-run-instances $IMAGE | grep INSTANCE | cut -f2`
|
SECGROUP=euca_secgroup
|
||||||
|
|
||||||
# assure it has booted within a reasonable time
|
# Add a secgroup
|
||||||
|
euca-add-group -d description $SECGROUP
|
||||||
|
|
||||||
|
# Launch it
|
||||||
|
INSTANCE=`euca-run-instances -g $SECGROUP -t m1.tiny $IMAGE | grep INSTANCE | cut -f2`
|
||||||
|
|
||||||
|
# Assure it has booted within a reasonable time
|
||||||
if ! timeout $RUNNING_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
|
if ! timeout $RUNNING_TIMEOUT sh -c "while euca-describe-instances $INSTANCE | grep -q running; do sleep 1; done"; then
|
||||||
echo "server didn't become active within $RUNNING_TIMEOUT seconds"
|
echo "server didn't become active within $RUNNING_TIMEOUT seconds"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Allocate floating address
|
||||||
|
FLOATING_IP=`euca-allocate-address | cut -f2`
|
||||||
|
|
||||||
|
# Release floating address
|
||||||
|
euca-associate-address -i $INSTANCE $FLOATING_IP
|
||||||
|
|
||||||
|
|
||||||
|
# Authorize pinging
|
||||||
|
euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
|
||||||
|
|
||||||
|
# Max time till the vm is bootable
|
||||||
|
BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
|
||||||
|
if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||||
|
echo "Couldn't ping server"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Revoke pinging
|
||||||
|
euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP
|
||||||
|
|
||||||
|
# Delete group
|
||||||
|
euca-delete-group $SECGROUP
|
||||||
|
|
||||||
|
# Release floating address
|
||||||
|
euca-disassociate-address $FLOATING_IP
|
||||||
|
|
||||||
|
# Release floating address
|
||||||
|
euca-release-address $FLOATING_IP
|
||||||
|
|
||||||
|
# Terminate instance
|
||||||
euca-terminate-instances $INSTANCE
|
euca-terminate-instances $INSTANCE
|
||||||
|
Loading…
Reference in New Issue
Block a user