Make exercise.sh with quantum work
- added support for quantum-debug command
- added ping and ssh method for quantum
Change-Id: Iebf8a0e9e2ed2bb56bee6533e69827e6caa2bc82
diff --git a/exercises/boot_from_volume.sh b/exercises/boot_from_volume.sh
index 460b50c..4c7890b 100755
--- a/exercises/boot_from_volume.sh
+++ b/exercises/boot_from_volume.sh
@@ -32,6 +32,12 @@
# Import configuration
source $TOP_DIR/openrc
+# Import quantum functions if needed
+if is_service_enabled quantum; then
+ source $TOP_DIR/lib/quantum
+ setup_quantum
+fi
+
# Import exercise configuration
source $TOP_DIR/exerciserc
@@ -168,6 +174,10 @@
# Delete a secgroup
nova secgroup-delete $SECGROUP || die "Failure deleting security group $SECGROUP"
+if is_service_enabled quantum; then
+ teardown_quantum
+fi
+
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
diff --git a/exercises/euca.sh b/exercises/euca.sh
index b121493..29141ec 100755
--- a/exercises/euca.sh
+++ b/exercises/euca.sh
@@ -33,6 +33,12 @@
# Import EC2 configuration
source $TOP_DIR/eucarc
+# Import quantum functions if needed
+if is_service_enabled quantum; then
+ source $TOP_DIR/lib/quantum
+ setup_quantum
+fi
+
# Import exercise configuration
source $TOP_DIR/exerciserc
@@ -169,6 +175,10 @@
# Delete group
euca-delete-group $SECGROUP || die "Failure deleting security group $SECGROUP"
+if is_service_enabled quantum; then
+ teardown_quantum
+fi
+
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh
index 6787878..ae5691f 100755
--- a/exercises/floating_ips.sh
+++ b/exercises/floating_ips.sh
@@ -31,6 +31,12 @@
# Import configuration
source $TOP_DIR/openrc
+# Import quantum functions if needed
+if is_service_enabled quantum; then
+ source $TOP_DIR/lib/quantum
+ setup_quantum
+fi
+
# Import exercise configuration
source $TOP_DIR/exerciserc
@@ -155,14 +161,16 @@
# test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
-# Allocate an IP from second floating pool
-TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1`
-die_if_not_set TEST_FLOATING_IP "Failure creating floating IP in $TEST_FLOATING_POOL"
+if ! is_service_enabled quantum; then
+ # Allocate an IP from second floating pool
+ TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1`
+ die_if_not_set TEST_FLOATING_IP "Failure creating floating IP in $TEST_FLOATING_POOL"
-# 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
+ # 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
fi
# dis-allow icmp traffic (ping)
@@ -171,12 +179,13 @@
# FIXME (anthony): make xs support security groups
if [ "$VIRT_DRIVER" != "xenserver" -a "$VIRT_DRIVER" != "openvz" ]; then
# test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds
- ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
+ ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT Fail
fi
-# Delete second floating IP
-nova floating-ip-delete $TEST_FLOATING_IP || die "Failure deleting floating IP $TEST_FLOATING_IP"
-
+if ! is_service_enabled quantum; then
+ # Delete second floating IP
+ nova floating-ip-delete $TEST_FLOATING_IP || die "Failure deleting floating IP $TEST_FLOATING_IP"
+fi
# de-allocate the floating ip
nova floating-ip-delete $FLOATING_IP || die "Failure deleting floating IP $FLOATING_IP"
@@ -193,6 +202,10 @@
# Delete a secgroup
nova secgroup-delete $SECGROUP || die "Failure deleting security group $SECGROUP"
+if is_service_enabled quantum; then
+ teardown_quantum
+fi
+
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
diff --git a/exercises/quantum-adv-test.sh b/exercises/quantum-adv-test.sh
index 8f15b63..2ee82ff 100755
--- a/exercises/quantum-adv-test.sh
+++ b/exercises/quantum-adv-test.sh
@@ -52,13 +52,17 @@
# Import configuration
source $TOP_DIR/openrc
-# Import exercise configuration
-source $TOP_DIR/exerciserc
-
# If quantum is not enabled we exit with exitcode 55 which mean
# exercise is skipped.
is_service_enabled quantum && is_service_enabled q-agt && is_service_enabled q-dhcp || exit 55
+# Import quantum fucntions
+source $TOP_DIR/lib/quantum
+setup_quantum
+
+# Import exercise configuration
+source $TOP_DIR/exerciserc
+
#------------------------------------------------------------------------------
# Test settings for quantum
#------------------------------------------------------------------------------
@@ -76,14 +80,14 @@
DEMO2_NUM_NET=2
PUBLIC_NET1_CIDR="200.0.0.0/24"
-DEMO1_NET1_CIDR="10.1.0.0/24"
-DEMO2_NET1_CIDR="10.2.0.0/24"
-DEMO2_NET2_CIDR="10.2.1.0/24"
+DEMO1_NET1_CIDR="10.10.0.0/24"
+DEMO2_NET1_CIDR="10.20.0.0/24"
+DEMO2_NET2_CIDR="10.20.1.0/24"
PUBLIC_NET1_GATEWAY="200.0.0.1"
-DEMO1_NET1_GATEWAY="10.1.0.1"
-DEMO2_NET1_GATEWAY="10.2.0.1"
-DEMO2_NET2_GATEWAY="10.2.1.1"
+DEMO1_NET1_GATEWAY="10.10.0.1"
+DEMO2_NET1_GATEWAY="10.20.0.1"
+DEMO2_NET2_GATEWAY="10.20.1.1"
PUBLIC_NUM_VM=1
DEMO1_NUM_VM=1
@@ -188,7 +192,7 @@
function confirm_server_active {
local VM_UUID=$1
- if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova --no_cache show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
+ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | grep -q ACTIVE; do sleep 1; done"; then
echo "server '$VM_UUID' did not become active!"
false
fi
@@ -232,6 +236,7 @@
source $TOP_DIR/openrc admin admin
add_tenant demo1 demo1 demo1
add_tenant demo2 demo2 demo2
+ source $TOP_DIR/openrc demo demo
}
function delete_tenants_and_users {
@@ -241,6 +246,7 @@
remove_user demo2
remove_tenant demo2
echo "removed all tenants"
+ source $TOP_DIR/openrc demo demo
}
function create_network {
@@ -256,12 +262,8 @@
source $TOP_DIR/openrc $TENANT $TENANT
local NET_ID=$(quantum net-create --tenant_id $TENANT_ID $NET_NAME $EXTRA| grep ' id ' | awk '{print $4}' )
quantum subnet-create --ip_version 4 --tenant_id $TENANT_ID --gateway $GATEWAY $NET_ID $CIDR
- #T0DO(nati) comment out until l3-agent is merged
- #local ROUTER_ID=$($QUANTUM router-create --tenant_id $TENANT_ID $ROUTER_NAME| grep ' id ' | awk '{print $4}' )
- #for NET_NAME in ${NET_NAMES//,/ };do
- # SUBNET_ID=`get_subnet_id $NET_NAME`
- # $QUANTUM router-interface-create $NAME --subnet_id $SUBNET_ID
- #done
+ quantum-debug probe-create $NET_ID
+ source $TOP_DIR/openrc demo demo
}
function create_networks {
@@ -285,7 +287,7 @@
done
#TODO (nati) Add multi-nic test
#TODO (nati) Add public-net test
- local VM_UUID=`nova --no_cache boot --flavor $(get_flavor_id m1.tiny) \
+ local VM_UUID=`nova boot --flavor $(get_flavor_id m1.tiny) \
--image $(get_image_id) \
$NIC \
$TENANT-server$NUM | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'`
@@ -301,32 +303,26 @@
# Test agent connection. Assumes namespaces are disabled, and
# that DHCP is in use, but not L3
local VM_NAME=$1
- IP=`nova --no_cache show $VM_NAME | grep 'network' | awk '{print $5}'`
- if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
- echo "Could not ping $VM_NAME"
- false
- fi
+ local NET_NAME=$2
+ IP=`nova show $VM_NAME | grep 'network' | awk '{print $5}'`
+ ping_check $NET_NAME $IP $BOOT_TIMEOUT
}
function check_vm {
local TENANT=$1
local NUM=$2
local VM_NAME="$TENANT-server$NUM"
+ local NET_NAME=$3
source $TOP_DIR/openrc $TENANT $TENANT
- ping_ip $VM_NAME
+ ping_ip $VM_NAME $NET_NAME
# TODO (nati) test ssh connection
# TODO (nati) test inter connection between vm
- # TODO (nati) test namespace dhcp
# TODO (nati) test dhcp host routes
# TODO (nati) test multi-nic
- # TODO (nati) use test-agent
- # TODO (nati) test L3 forwarding
- # TODO (nati) test floating ip
- # TODO (nati) test security group
}
function check_vms {
- foreach_tenant_vm 'check_vm ${%TENANT%_NAME} %NUM%'
+ foreach_tenant_vm 'check_vm ${%TENANT%_NAME} %NUM% ${%TENANT%_VM%NUM%_NET}'
}
function shutdown_vm {
@@ -334,12 +330,12 @@
local NUM=$2
source $TOP_DIR/openrc $TENANT $TENANT
VM_NAME=${TENANT}-server$NUM
- nova --no_cache delete $VM_NAME
+ nova delete $VM_NAME
}
function shutdown_vms {
foreach_tenant_vm 'shutdown_vm ${%TENANT%_NAME} %NUM%'
- if ! timeout $TERMINATE_TIMEOUT sh -c "while nova --no_cache list | grep -q ACTIVE; do sleep 1; done"; then
+ if ! timeout $TERMINATE_TIMEOUT sh -c "while nova list | grep -q ACTIVE; do sleep 1; done"; then
echo "Some VMs failed to shutdown"
false
fi
@@ -347,17 +343,22 @@
function delete_network {
local TENANT=$1
+ local NUM=$2
+ local NET_NAME="${TENANT}-net$NUM"
source $TOP_DIR/openrc admin admin
local TENANT_ID=$(get_tenant_id $TENANT)
#TODO(nati) comment out until l3-agent merged
#for res in port subnet net router;do
- for res in port subnet net;do
- quantum ${res}-list -F id -F tenant_id | grep $TENANT_ID | awk '{print $2}' | xargs -I % quantum ${res}-delete %
+ for net_id in `quantum net-list -c id -c name | grep $NET_NAME | awk '{print $2}'`;do
+ delete_probe $net_id
+ quantum subnet-list | grep $net_id | awk '{print $2}' | xargs -I% quantum subnet-delete %
+ quantum net-delete $net_id
done
+ source $TOP_DIR/openrc demo demo
}
function delete_networks {
- foreach_tenant 'delete_network ${%TENANT%_NAME}'
+ foreach_tenant_net 'delete_network ${%TENANT%_NAME} ${%NUM%}'
#TODO(nati) add secuirty group check after it is implemented
# source $TOP_DIR/openrc demo1 demo1
# nova secgroup-delete-rule default icmp -1 -1 0.0.0.0/0
@@ -474,6 +475,7 @@
}
+teardown_quantum
#-------------------------------------------------------------------------------
# Kick off script.
#-------------------------------------------------------------------------------
diff --git a/exercises/volumes.sh b/exercises/volumes.sh
index 1c73786..8533993 100755
--- a/exercises/volumes.sh
+++ b/exercises/volumes.sh
@@ -30,6 +30,12 @@
# Import configuration
source $TOP_DIR/openrc
+# Import quantum functions if needed
+if is_service_enabled quantum; then
+ source $TOP_DIR/lib/quantum
+ setup_quantum
+fi
+
# Import exercise configuration
source $TOP_DIR/exerciserc
@@ -206,6 +212,10 @@
# Delete a secgroup
nova secgroup-delete $SECGROUP || die "Failure deleting security group $SECGROUP"
+if is_service_enabled quantum; then
+ teardown_quantum
+fi
+
set +o xtrace
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"