From 696ad331a4af3a0d259b1db7eed5ef6b691ba045 Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 10 Jan 2012 15:34:34 -0600 Subject: [PATCH] Add some additional floating ip pool testing Change-Id: I62cd6b43e3250dc28d66dc84d3759f47e81ff134 --- exercises/floating_ips.sh | 28 ++++++++++++++++++++++++---- stack.sh | 8 ++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh index 135c8c1c34..9c207cd8dc 100755 --- a/exercises/floating_ips.sh +++ b/exercises/floating_ips.sh @@ -24,6 +24,11 @@ pushd $(cd $(dirname "$0")/.. && pwd) 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 @@ nova secgroup-add-rule $SECGROUP icmp -1 -1 0.0.0.0/0 # 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 @@ if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sle 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 @@ fi # 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 c0763d46a3..c3d84d24c3 100755 --- a/stack.sh +++ b/stack.sh @@ -283,6 +283,11 @@ EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST} 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 @@ if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then 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