Change-Id: I62cd6b43e3250dc28d66dc84d3759f47e81ff134
| ... | ... |
@@ -24,6 +24,11 @@ pushd $(cd $(dirname "$0")/.. && pwd) |
| 24 | 24 |
source ./openrc |
| 25 | 25 |
popd |
| 26 | 26 |
|
| 27 |
+# Set some defaults |
|
| 28 |
+ |
|
| 29 |
+DEFAULT_FLOATING_POOL=${DEFAULT_FLOATING_POOL:-nova}
|
|
| 30 |
+TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test}
|
|
| 31 |
+ |
|
| 27 | 32 |
# Get a token for clients that don't support service catalog |
| 28 | 33 |
# ========================================================== |
| 29 | 34 |
|
| ... | ... |
@@ -130,11 +135,14 @@ nova secgroup-add-rule $SECGROUP icmp -1 -1 0.0.0.0/0 |
| 130 | 130 |
# List rules for a secgroup |
| 131 | 131 |
nova secgroup-list-rules $SECGROUP |
| 132 | 132 |
|
| 133 |
-# allocate a floating ip |
|
| 134 |
-nova floating-ip-create |
|
| 133 |
+# allocate a floating ip from default pool |
|
| 134 |
+FLOATING_IP=`nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | cut -d '|' -f2` |
|
| 135 | 135 |
|
| 136 |
-# store floating address |
|
| 137 |
-FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed 's/ //g'` |
|
| 136 |
+# list floating addresses |
|
| 137 |
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep -q $FLOATING_IP; do sleep 1; done"; then |
|
| 138 |
+ echo "Floating IP not allocated" |
|
| 139 |
+ exit 1 |
|
| 140 |
+fi |
|
| 138 | 141 |
|
| 139 | 142 |
# add floating ip to our server |
| 140 | 143 |
nova add-floating-ip $NAME $FLOATING_IP |
| ... | ... |
@@ -145,6 +153,15 @@ if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sle |
| 145 | 145 |
exit 1 |
| 146 | 146 |
fi |
| 147 | 147 |
|
| 148 |
+# Allocate an IP from it |
|
| 149 |
+TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | cut -d '|' -f2` |
|
| 150 |
+ |
|
| 151 |
+# list floating addresses |
|
| 152 |
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep $TEST_FLOATING_POOL | grep -q $TEST_FLOATING_IP; do sleep 1; done"; then |
|
| 153 |
+ echo "Floating IP not allocated" |
|
| 154 |
+ exit 1 |
|
| 155 |
+fi |
|
| 156 |
+ |
|
| 148 | 157 |
# dis-allow icmp traffic (ping) |
| 149 | 158 |
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 |
| 150 | 159 |
|
| ... | ... |
@@ -161,6 +178,9 @@ fi |
| 161 | 161 |
# de-allocate the floating ip |
| 162 | 162 |
nova floating-ip-delete $FLOATING_IP |
| 163 | 163 |
|
| 164 |
+# Delete second floating IP |
|
| 165 |
+nova floating-ip-delete $TEST_FLOATING_IP |
|
| 166 |
+ |
|
| 164 | 167 |
# shutdown the server |
| 165 | 168 |
nova delete $NAME |
| 166 | 169 |
|
| ... | ... |
@@ -283,6 +283,11 @@ EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST}
|
| 283 | 283 |
FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
|
| 284 | 284 |
VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE}
|
| 285 | 285 |
|
| 286 |
+# Test floating pool and range are used for testing. They are defined |
|
| 287 |
+# here until the admin APIs can replace nova-manage |
|
| 288 |
+TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test}
|
|
| 289 |
+TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29}
|
|
| 290 |
+ |
|
| 286 | 291 |
# Multi-host is a mode where each compute node runs its own network node. This |
| 287 | 292 |
# allows network operations and routing for a VM to occur on the server that is |
| 288 | 293 |
# running the VM - removing a SPOF and bandwidth bottleneck. |
| ... | ... |
@@ -1327,6 +1332,9 @@ if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then |
| 1327 | 1327 |
else |
| 1328 | 1328 |
# create some floating ips |
| 1329 | 1329 |
$NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE |
| 1330 |
+ |
|
| 1331 |
+ # create a second pool |
|
| 1332 |
+ $NOVA_DIR/bin/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL |
|
| 1330 | 1333 |
fi |
| 1331 | 1334 |
fi |
| 1332 | 1335 |
|