Add some additional floating ip pool testing
Change-Id: I62cd6b43e3250dc28d66dc84d3759f47e81ff134
diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh
index 135c8c1..9c207cd 100755
--- a/exercises/floating_ips.sh
+++ b/exercises/floating_ips.sh
@@ -24,6 +24,11 @@
source ./openrc
popd
+# Set some defaults
+
+DEFAULT_FLOATING_POOL=${DEFAULT_FLOATING_POOL:-nova}
+TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test}
+
# Get a token for clients that don't support service catalog
# ==========================================================
@@ -130,11 +135,14 @@
# List rules for a secgroup
nova secgroup-list-rules $SECGROUP
-# allocate a floating ip
-nova floating-ip-create
+# allocate a floating ip from default pool
+FLOATING_IP=`nova floating-ip-create | grep $DEFAULT_FLOATING_POOL | cut -d '|' -f2`
-# store floating address
-FLOATING_IP=`nova floating-ip-list | grep None | head -1 | cut -d '|' -f2 | sed 's/ //g'`
+# list floating addresses
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! nova floating-ip-list | grep -q $FLOATING_IP; do sleep 1; done"; then
+ echo "Floating IP not allocated"
+ exit 1
+fi
# add floating ip to our server
nova add-floating-ip $NAME $FLOATING_IP
@@ -145,6 +153,15 @@
exit 1
fi
+# Allocate an IP from it
+TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | cut -d '|' -f2`
+
+# list floating addresses
+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
+ echo "Floating IP not allocated"
+ exit 1
+fi
+
# dis-allow icmp traffic (ping)
nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0
@@ -161,6 +178,9 @@
# de-allocate the floating ip
nova floating-ip-delete $FLOATING_IP
+# Delete second floating IP
+nova floating-ip-delete $TEST_FLOATING_IP
+
# shutdown the server
nova delete $NAME
diff --git a/stack.sh b/stack.sh
index c0763d4..c3d84d2 100755
--- a/stack.sh
+++ b/stack.sh
@@ -283,6 +283,11 @@
FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE}
+# Test floating pool and range are used for testing. They are defined
+# here until the admin APIs can replace nova-manage
+TEST_FLOATING_POOL=${TEST_FLOATING_POOL:-test}
+TEST_FLOATING_RANGE=${TEST_FLOATING_RANGE:-192.168.253.0/29}
+
# Multi-host is a mode where each compute node runs its own network node. This
# allows network operations and routing for a VM to occur on the server that is
# running the VM - removing a SPOF and bandwidth bottleneck.
@@ -1327,6 +1332,9 @@
else
# create some floating ips
$NOVA_DIR/bin/nova-manage floating create $FLOATING_RANGE
+
+ # create a second pool
+ $NOVA_DIR/bin/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
fi
fi