more converting sleep -> timeouts
This commit is contained in:
parent
ab8dbce751
commit
5a774839d7
1 changed files with 13 additions and 13 deletions
26
exercise.sh
26
exercise.sh
|
@ -82,11 +82,11 @@ nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP
|
||||||
# Waiting for boot
|
# Waiting for boot
|
||||||
# ----------------
|
# ----------------
|
||||||
|
|
||||||
# let's give it 5 seconds to launch
|
# check that the status is active within 10 seconds
|
||||||
sleep 5
|
if ! timeout 10 sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then
|
||||||
|
echo "server didn't become active!"
|
||||||
# check that the status is active
|
exit 1
|
||||||
nova show $NAME | grep status | grep -q ACTIVE
|
fi
|
||||||
|
|
||||||
# get the IP of the server
|
# get the IP of the server
|
||||||
IP=`nova show $NAME | grep "private network" | cut -d"|" -f3`
|
IP=`nova show $NAME | grep "private network" | cut -d"|" -f3`
|
||||||
|
@ -121,21 +121,21 @@ FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed
|
||||||
# add floating ip to our server
|
# add floating ip to our server
|
||||||
nova add-floating-ip $NAME $FLOATING_IP
|
nova add-floating-ip $NAME $FLOATING_IP
|
||||||
|
|
||||||
# sleep for a smidge
|
# test we can ping our floating ip within 10 seconds
|
||||||
sleep 5
|
if ! timeout 10 sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||||
|
echo "Couldn't ping server with floating ip"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# ping our floating ip
|
|
||||||
ping -c1 -w1 $FLOATING_IP
|
ping -c1 -w1 $FLOATING_IP
|
||||||
|
|
||||||
# dis-allow icmp traffic (ping)
|
# dis-allow icmp traffic (ping)
|
||||||
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0
|
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0
|
||||||
|
|
||||||
# sleep for a smidge
|
# test we can aren't able to ping our floating ip within 10 seconds
|
||||||
sleep 5
|
if ! timeout 10 sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||||
|
|
||||||
# ping our floating ip
|
|
||||||
if ( ping -c1 -w1 $FLOATING_IP ); then
|
|
||||||
print "Security group failure - ping should not be allowed!"
|
print "Security group failure - ping should not be allowed!"
|
||||||
|
echo "Couldn't ping server with floating ip"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue