|
...
|
...
|
@@ -82,8 +82,17 @@ nova boot --flavor $FLAVOR --image $IMAGE $NAME --security_groups=$SECGROUP
|
|
82
|
82
|
# Waiting for boot
|
|
83
|
83
|
# ----------------
|
|
84
|
84
|
|
|
85
|
|
-# check that the status is active within 10 seconds
|
|
86
|
|
-if ! timeout 10 sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then
|
|
|
85
|
+# Max time to wait while vm goes from build to active state
|
|
|
86
|
+ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-10}
|
|
|
87
|
+
|
|
|
88
|
+# Max time till the vm is bootable
|
|
|
89
|
+BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
|
|
|
90
|
+
|
|
|
91
|
+# Max time to wait for proper association and dis-association.
|
|
|
92
|
+ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10}
|
|
|
93
|
+
|
|
|
94
|
+# check that the status is active within ACTIVE_TIMEOUT seconds
|
|
|
95
|
+if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then
|
|
87
|
96
|
echo "server didn't become active!"
|
|
88
|
97
|
exit 1
|
|
89
|
98
|
fi
|
|
...
|
...
|
@@ -95,12 +104,15 @@ IP=`nova show $NAME | grep "private network" | cut -d"|" -f3`
|
|
95
|
95
|
MULTI_HOST=${MULTI_HOST:-0}
|
|
96
|
96
|
if [ "$MULTI_HOST" = "0" ]; then
|
|
97
|
97
|
# sometimes the first ping fails (10 seconds isn't enough time for the VM's
|
|
98
|
|
- # network to respond?), so let's ping for 15 seconds with a timeout
|
|
99
|
|
- # of a second.
|
|
100
|
|
- if ! timeout 15 sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
|
|
|
98
|
+ # network to respond?), so let's ping for a default of 15 seconds with a
|
|
|
99
|
+ # timeout of a second for each ping.
|
|
|
100
|
+ if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
|
|
101
|
101
|
echo "Couldn't ping server"
|
|
102
|
102
|
exit 1
|
|
103
|
103
|
fi
|
|
|
104
|
+else
|
|
|
105
|
+ # On a multi-host system, without vm net access, do a sleep to wait for the boot
|
|
|
106
|
+ sleep $BOOT_TIMEOUT
|
|
104
|
107
|
fi
|
|
105
|
108
|
|
|
106
|
109
|
# Security Groups & Floating IPs
|
|
...
|
...
|
@@ -121,8 +133,8 @@ FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed
|
|
121
|
121
|
# add floating ip to our server
|
|
122
|
122
|
nova add-floating-ip $NAME $FLOATING_IP
|
|
123
|
123
|
|
|
124
|
|
-# test we can ping our floating ip within 10 seconds
|
|
125
|
|
-if ! timeout 10 sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
|
|
124
|
+# test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
|
|
|
125
|
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
|
126
|
126
|
echo "Couldn't ping server with floating ip"
|
|
127
|
127
|
exit 1
|
|
128
|
128
|
fi
|
|
...
|
...
|
@@ -152,8 +164,8 @@ ping -c1 -w1 $IP
|
|
152
|
152
|
# dis-allow icmp traffic (ping)
|
|
153
|
153
|
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0
|
|
154
|
154
|
|
|
155
|
|
-# test we can aren't able to ping our floating ip within 10 seconds
|
|
156
|
|
-if ! timeout 10 sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
|
|
155
|
+# test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds
|
|
|
156
|
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
|
157
|
157
|
print "Security group failure - ping should not be allowed!"
|
|
158
|
158
|
echo "Couldn't ping server with floating ip"
|
|
159
|
159
|
exit 1
|