Wait for javelin instance to start

This commit is contained in:
Dean Troyer 2013-03-07 15:54:04 -06:00
parent 7a142b7ede
commit 290417c134
2 changed files with 11 additions and 8 deletions

View File

@ -52,6 +52,7 @@ NOVACLIENT_DIR=python-novaclient
NOVA_DIR=nova
# Timeouts
ACTIVE_TIMEOUT=120
SERVICE_TIMEOUT=120
# Allow local overrides of env variables

View File

@ -96,9 +96,8 @@ fi
# Create our secgroup
if ! nova secgroup-list | grep -q $JAVELIN_SECGROUP; then
nova secgroup-create $JAVELIN_SECGROUP "$JPROJECT access rules"
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova secgroup-list | grep -q $JAVELIN_SECGROUP; do sleep 1; done"; then
echo "$JAVELIN_SECGROUP security group not created"
exit 1
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova secgroup-list | grep -q $JAVELIN_SECGROUP; do sleep 1; done"; then
die "$JAVELIN_SECGROUP security group not created"
fi
fi
@ -125,8 +124,7 @@ fi
if ! nova volume-list | grep -q $JAVELIN_VOLUME; then
nova volume-create --display_name=$JAVELIN_VOLUME 1
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova volume-list | grep $JAVELIN_VOLUME | grep -q available; do sleep 1; done"; then
echo "$JAVELIN_VOLUME volume not created"
exit 1
die "$JAVELIN_VOLUME volume not created"
fi
fi
@ -137,7 +135,11 @@ fi
BOOT_TXT=$(nova boot --flavor "$FLAVOR" --image "$IMAGE" $JSERVER | awk "/adminPass/ { print \$2 \"=\" \$4 };/ id / { print \$2 \"=\" \$4 }"; exit ${PIPESTATUS[0]})
ret=$?
if [[ ! $ret = 0 ]]; then
echo "Failed to boot $JSERVER"
exit 1
die "Failed to boot $JSERVER"
fi
eval $BOOT_TXT
# Check that the status is active within ACTIVE_TIMEOUT seconds
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $id | grep status | grep -q ACTIVE; do sleep 1; done"; then
die "server didn't become active!"
fi
eval $BOOT_TXT