diff --git a/exercises/quantum-adv-test.sh b/exercises/quantum-adv-test.sh new file mode 100755 index 0000000000..cff29d2e3e --- /dev/null +++ b/exercises/quantum-adv-test.sh @@ -0,0 +1,486 @@ +#!/usr/bin/env bash +# + +# **quantum.sh** + +# We will use this test to perform integration testing of nova and +# other components with Quantum. + +echo "*********************************************************************" +echo "Begin DevStack Exercise: $0" +echo "*********************************************************************" + +# This script exits on an error so that errors don't compound and you see +# only the first error that occured. + +set -o errtrace +trap failed ERR +failed() { + local r=$? + set +o errtrace + set +o xtrace + echo "Failed to execute" + echo "Starting cleanup..." + delete_all + echo "Finished cleanup" + exit $r +} + +# Print the commands being run so that we can see the command that triggers +# an error. It is also useful for following allowing as the install occurs. +set -o xtrace + +#------------------------------------------------------------------------------ +# Quantum config check +#------------------------------------------------------------------------------ +# Warn if quantum is not enabled +if [[ ! "$ENABLED_SERVICES" =~ "q-svc" ]]; then + echo "WARNING: Running quantum test without enabling quantum" +fi + +#------------------------------------------------------------------------------ +# Environment +#------------------------------------------------------------------------------ + +# Keep track of the current directory +EXERCISE_DIR=$(cd $(dirname "$0") && pwd) +TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) + +# Import common functions +source $TOP_DIR/functions + +# 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 + +#------------------------------------------------------------------------------ +# Test settings for quantum +#------------------------------------------------------------------------------ + +TENANTS="DEMO1" +# TODO (nati)_Test public network +#TENANTS="DEMO1,DEMO2" + +PUBLIC_NAME="admin" +DEMO1_NAME="demo1" +DEMO2_NAME="demo2" + +PUBLIC_NUM_NET=1 +DEMO1_NUM_NET=1 +DEMO2_NUM_NET=2 + +PUBLIC_NET1_CIDR="200.0.0.0/24" +DEMO1_NET1_CIDR="190.0.0.0/24" +DEMO2_NET1_CIDR="191.0.0.0/24" +DEMO2_NET2_CIDR="191.0.1.0/24" + +PUBLIC_NET1_GATEWAY="200.0.0.1" +DEMO1_NET1_GATEWAY="190.0.0.1" +DEMO2_NET1_GATEWAY="191.0.0.1" +DEMO2_NET2_GATEWAY="191.0.1.1" + +PUBLIC_NUM_VM=1 +DEMO1_NUM_VM=1 +DEMO2_NUM_VM=2 + +PUBLIC_VM1_NET='admin-net1' +DEMO1_VM1_NET='demo1-net1' +# Multinic settings. But this is fail without nic setting in OS image +DEMO2_VM1_NET='demo2-net1' +DEMO2_VM2_NET='demo2-net2' + +PUBLIC_NUM_ROUTER=1 +DEMO1_NUM_ROUTER=1 +DEMO2_NUM_ROUTER=1 + +PUBLIC_ROUTER1_NET="admin-net1" +DEMO1_ROUTER1_NET="demo1-net1" +DEMO2_ROUTER1_NET="demo2-net1" + +#------------------------------------------------------------------------------ +# Keystone settings. +#------------------------------------------------------------------------------ +KEYSTONE="keystone" + +#------------------------------------------------------------------------------ +# Get a token for clients that don't support service catalog +#------------------------------------------------------------------------------ + +# manually create a token by querying keystone (sending JSON data). Keystone +# returns a token and catalog of endpoints. We use python to parse the token +# and save it. + +TOKEN=`keystone token-get | grep ' id ' | awk '{print $4}'` + +#------------------------------------------------------------------------------ +# Various functions. +#------------------------------------------------------------------------------ +function foreach_tenant { + COMMAND=$1 + for TENANT in ${TENANTS//,/ };do + eval ${COMMAND//%TENANT%/$TENANT} + done +} + +function foreach_tenant_resource { + COMMAND=$1 + RESOURCE=$2 + for TENANT in ${TENANTS//,/ };do + eval 'NUM=$'"${TENANT}_NUM_$RESOURCE" + for i in `seq $NUM`;do + local COMMAND_LOCAL=${COMMAND//%TENANT%/$TENANT} + COMMAND_LOCAL=${COMMAND_LOCAL//%NUM%/$i} + eval $COMMAND_LOCAL + done + done +} + +function foreach_tenant_vm { + COMMAND=$1 + foreach_tenant_resource "$COMMAND" 'VM' +} + +function foreach_tenant_net { + COMMAND=$1 + foreach_tenant_resource "$COMMAND" 'NET' +} + +function get_image_id { + local IMAGE_ID=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) + echo "$IMAGE_ID" +} + +function get_tenant_id { + local TENANT_NAME=$1 + local TENANT_ID=`keystone tenant-list | grep " $TENANT_NAME " | head -n 1 | get_field 1` + echo "$TENANT_ID" +} + +function get_user_id { + local USER_NAME=$1 + local USER_ID=`keystone user-list | grep $USER_NAME | awk '{print $2}'` + echo "$USER_ID" +} + +function get_role_id { + local ROLE_NAME=$1 + local ROLE_ID=`keystone role-list | grep $ROLE_NAME | awk '{print $2}'` + echo "$ROLE_ID" +} + +function get_network_id { + local NETWORK_NAME="$1" + local NETWORK_ID=`quantum net-list -F id -- --name=$NETWORK_NAME | awk "NR==4" | awk '{print $2}'` + echo $NETWORK_ID +} + +function get_flavor_id { + local INSTANCE_TYPE=$1 + local FLAVOR_ID=`nova flavor-list | grep $INSTANCE_TYPE | awk '{print $2}'` + echo "$FLAVOR_ID" +} + +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 + echo "server '$VM_UUID' did not become active!" + false +fi + +} + +function add_tenant { + local TENANT=$1 + local USER=$2 + + $KEYSTONE tenant-create --name=$TENANT + $KEYSTONE user-create --name=$USER --pass=${ADMIN_PASSWORD} + + local USER_ID=$(get_user_id $USER) + local TENANT_ID=$(get_tenant_id $TENANT) + + $KEYSTONE user-role-add --user-id $USER_ID --role-id $(get_role_id Member) --tenant-id $TENANT_ID +} + +function remove_tenant { + local TENANT=$1 + local TENANT_ID=$(get_tenant_id $TENANT) + + $KEYSTONE tenant-delete $TENANT_ID +} + +function remove_user { + local USER=$1 + local USER_ID=$(get_user_id $USER) + + $KEYSTONE user-delete $USER_ID +} + + + +#------------------------------------------------------------------------------ +# "Create" functions +#------------------------------------------------------------------------------ + +function create_tenants { + source $TOP_DIR/openrc admin admin + add_tenant demo1 demo1 demo1 + add_tenant demo2 demo2 demo2 +} + +function delete_tenants_and_users { + source $TOP_DIR/openrc admin admin + remove_user demo1 + remove_tenant demo1 + remove_user demo2 + remove_tenant demo2 + echo "removed all tenants" +} + +function create_network { + local TENANT=$1 + local GATEWAY=$2 + local CIDR=$3 + local NUM=$4 + local EXTRA=$5 + local NET_NAME="${TENANT}-net$NUM" + local ROUTER_NAME="${TENANT}-router${NUM}" + source $TOP_DIR/openrc admin admin + local TENANT_ID=$(get_tenant_id $TENANT) + 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 +} + +function create_networks { + foreach_tenant_net 'create_network ${%TENANT%_NAME} ${%TENANT%_NET%NUM%_GATEWAY} ${%TENANT%_NET%NUM%_CIDR} %NUM% ${%TENANT%_NET%NUM%_EXTRA}' + #TODO(nati) test security group function + # allow ICMP for both tenant's security groups + #source $TOP_DIR/openrc demo1 demo1 + #$NOVA secgroup-add-rule default icmp -1 -1 0.0.0.0/0 + #source $TOP_DIR/openrc demo2 demo2 + #$NOVA secgroup-add-rule default icmp -1 -1 0.0.0.0/0 +} + +function create_vm { + local TENANT=$1 + local NUM=$2 + local NET_NAMES=$3 + source $TOP_DIR/openrc $TENANT $TENANT + local NIC="" + for NET_NAME in ${NET_NAMES//,/ };do + NIC="$NIC --nic net-id="`get_network_id $NET_NAME` + 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) \ + --image $(get_image_id) \ + $NIC \ + $TENANT-server$NUM | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'` + die_if_not_set VM_UUID "Failure launching $TENANT-server$NUM" VM_UUID + confirm_server_active $VM_UUID +} + +function create_vms { + foreach_tenant_vm 'create_vm ${%TENANT%_NAME} %NUM% ${%TENANT%_VM%NUM%_NET}' +} + +function ping_ip { + # 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 +} + +function check_vm { + local TENANT=$1 + local NUM=$2 + local VM_NAME="$TENANT-server$NUM" + source $TOP_DIR/openrc $TENANT $TENANT + ping_ip $VM_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%' +} + +function shutdown_vm { + local TENANT=$1 + local NUM=$2 + source $TOP_DIR/openrc $TENANT $TENANT + VM_NAME=${TENANT}-server$NUM + nova --no_cache 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 + echo "Some VMs failed to shutdown" + false + fi +} + +function delete_network { + local TENANT=$1 + 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 % + done +} + +function delete_networks { + foreach_tenant 'delete_network ${%TENANT%_NAME}' + #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 + # source $TOP_DIR/openrc demo2 demo2 + # nova secgroup-delete-rule default icmp -1 -1 0.0.0.0/0 +} + +function create_all { + create_tenants + create_networks + create_vms +} + +function delete_all { + shutdown_vms + delete_networks + delete_tenants_and_users +} + +function all { + create_all + check_vms + delete_all +} + +#------------------------------------------------------------------------------ +# Test functions. +#------------------------------------------------------------------------------ +function test_functions { + IMAGE=$(get_image_id) + echo $IMAGE + + TENANT_ID=$(get_tenant_id demo) + echo $TENANT_ID + + FLAVOR_ID=$(get_flavor_id m1.tiny) + echo $FLAVOR_ID + + NETWORK_ID=$(get_network_id admin) + echo $NETWORK_ID +} + +#------------------------------------------------------------------------------ +# Usage and main. +#------------------------------------------------------------------------------ +usage() { + echo "$0: [-h]" + echo " -h, --help Display help message" + echo " -t, --tenant Create tenants" + echo " -n, --net Create networks" + echo " -v, --vm Create vms" + echo " -c, --check Check connection" + echo " -x, --delete-tenants Delete tenants" + echo " -y, --delete-nets Delete networks" + echo " -z, --delete-vms Delete vms" + echo " -T, --test Test functions" +} + +main() { + + echo Description + echo + echo Copyright 2012, Cisco Systems + echo Copyright 2012, Nicira Networks, Inc. + echo Copyright 2012, NTT MCL, Inc. + echo + echo Please direct any questions to dedutta@cisco.com, dan@nicira.com, nachi@nttmcl.com + echo + + + if [ $# -eq 0 ] ; then + # if no args are provided, run all tests + all + else + + while [ "$1" != "" ]; do + case $1 in + -h | --help ) usage + exit + ;; + -n | --net ) create_networks + exit + ;; + -v | --vm ) create_vms + exit + ;; + -t | --tenant ) create_tenants + exit + ;; + -c | --check ) check_vms + exit + ;; + -T | --test ) test_functions + exit + ;; + -x | --delete-tenants ) delete_tenants_and_users + exit + ;; + -y | --delete-nets ) delete_networks + exit + ;; + -z | --delete-vms ) shutdown_vms + exit + ;; + -a | --all ) all + exit + ;; + * ) usage + exit 1 + esac + shift + done + fi +} + + +#------------------------------------------------------------------------------- +# Kick off script. +#------------------------------------------------------------------------------- +echo $* +main $* + +set +o xtrace +echo "*********************************************************************" +echo "SUCCESS: End DevStack Exercise: $0" +echo "*********************************************************************" diff --git a/exercises/quantum.sh b/exercises/quantum.sh deleted file mode 100755 index 33ae14ea92..0000000000 --- a/exercises/quantum.sh +++ /dev/null @@ -1,396 +0,0 @@ -#!/usr/bin/env bash -# - -# **quantum.sh** - -# We will use this test to perform integration testing of nova and -# other components with Quantum. - -echo "*********************************************************************" -echo "Begin DevStack Exercise: $0" -echo "*********************************************************************" - -# This script exits on an error so that errors don't compound and you see -# only the first error that occured. -set -o errexit - -# Print the commands being run so that we can see the command that triggers -# an error. It is also useful for following allowing as the install occurs. -set -o xtrace - -#------------------------------------------------------------------------------ -# Quantum config check -#------------------------------------------------------------------------------ -# Warn if quantum is not enabled -if [[ ! "$ENABLED_SERVICES" =~ "q-svc" ]]; then - echo "WARNING: Running quantum test without enabling quantum" -fi - -#------------------------------------------------------------------------------ -# Environment -#------------------------------------------------------------------------------ - -# Keep track of the current directory -EXERCISE_DIR=$(cd $(dirname "$0") && pwd) -TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) - -# Import common functions -source $TOP_DIR/functions - -# 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 || exit 55 - -#------------------------------------------------------------------------------ -# Various default parameters. -#------------------------------------------------------------------------------ - -# Max time to wait while vm goes from build to active state -ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-30} - -# Max time till the vm is bootable -BOOT_TIMEOUT=${BOOT_TIMEOUT:-60} - -# Max time to wait for proper association and dis-association. -ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-15} - -# Max time to wait before delete VMs and delete Networks -VM_NET_DELETE_TIMEOUT=${VM_NET_TIMEOUT:-10} - -# Instance type to create -DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny} - -# Boot this image, use first AMi image if unset -DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ami} - -# OVS Hosts -OVS_HOSTS=${DEFAULT_OVS_HOSTS:-"localhost"} - -#------------------------------------------------------------------------------ -# Nova settings. -#------------------------------------------------------------------------------ -if [ -f /opt/stack/nova/bin/nova-manage ] ; then - NOVA_MANAGE=/opt/stack/nova/bin/nova-manage -else - NOVA_MANAGE=/usr/local/bin/nova-manage -NOVA=/usr/local/bin/nova -NOVA_CONF=/etc/nova/nova.conf - -#------------------------------------------------------------------------------ -# Mysql settings. -#------------------------------------------------------------------------------ -MYSQL="/usr/bin/mysql --skip-column-name --host=$MYSQL_HOST" - -#------------------------------------------------------------------------------ -# Keystone settings. -#------------------------------------------------------------------------------ -KEYSTONE="keystone" - -#------------------------------------------------------------------------------ -# Get a token for clients that don't support service catalog -#------------------------------------------------------------------------------ - -# manually create a token by querying keystone (sending JSON data). Keystone -# returns a token and catalog of endpoints. We use python to parse the token -# and save it. - -TOKEN=`keystone token-get | grep ' id ' | awk '{print $4}'` - -#------------------------------------------------------------------------------ -# Various functions. -#------------------------------------------------------------------------------ -function get_image_id { - local IMAGE_ID=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1) - echo "$IMAGE_ID" -} - -function get_tenant_id { - local TENANT_NAME=$1 - local TENANT_ID=`keystone tenant-list | grep $TENANT_NAME | awk '{print $2}'` - echo "$TENANT_ID" -} - -function get_user_id { - local USER_NAME=$1 - local USER_ID=`keystone user-list | grep $USER_NAME | awk '{print $2}'` - echo "$USER_ID" -} - -function get_role_id { - local ROLE_NAME=$1 - local ROLE_ID=`keystone role-list | grep $ROLE_NAME | awk '{print $2}'` - echo "$ROLE_ID" -} - -# TODO: (Debo) Change Quantum client CLI and then remove the MYSQL stuff. -function get_network_id { - local NETWORK_NAME=$1 - local QUERY="select uuid from networks where label='$NETWORK_NAME'" - local NETWORK_ID=`echo $QUERY | $MYSQL -u root -p$MYSQL_PASSWORD nova` - echo "$NETWORK_ID" -} - -function get_flavor_id { - local INSTANCE_TYPE=$1 - local FLAVOR_ID=`nova flavor-list | grep $INSTANCE_TYPE | awk '{print $2}'` - echo "$FLAVOR_ID" -} - -function add_tenant { - local TENANT=$1 - local USER=$3 - local PASSWORD=$2 - - $KEYSTONE tenant-create --name=$TENANT - $KEYSTONE user-create --name=$USER --pass=${PASSWORD} - - local USER_ID=$(get_user_id $USER) - local TENANT_ID=$(get_tenant_id $TENANT) - - $KEYSTONE user-role-add --user $USER_ID --role $(get_role_id Member) --tenant_id $TENANT_ID - $KEYSTONE user-role-add --user $USER_ID --role $(get_role_id admin) --tenant_id $TENANT_ID - $KEYSTONE user-role-add --user $USER_ID --role $(get_role_id anotherrole) --tenant_id $TENANT_ID - #$KEYSTONE user-role-add --user $USER_ID --role $(get_role_id sysadmin) --tenant_id $TENANT_ID - #$KEYSTONE user-role-add --user $USER_ID --role $(get_role_id netadmin) --tenant_id $TENANT_ID -} - -function remove_tenant { - local TENANT=$1 - local TENANT_ID=$(get_tenant_id $TENANT) - - $KEYSTONE tenant-delete $TENANT_ID -} - -function remove_user { - local USER=$1 - local USER_ID=$(get_user_id $USER) - - $KEYSTONE user-delete $USER_ID -} - - -#------------------------------------------------------------------------------ -# "Create" functions -#------------------------------------------------------------------------------ - -function create_tenants { - add_tenant demo1 nova demo1 - add_tenant demo2 nova demo2 -} - -function delete_tenants_and_users { - remove_tenant demo1 - remove_tenant demo2 - remove_user demo1 - remove_user demo2 -} - -function create_networks { - $NOVA_MANAGE --flagfile=$NOVA_CONF network create \ - --label=public-net1 \ - --fixed_range_v4=11.0.0.0/24 - - $NOVA_MANAGE --flagfile=$NOVA_CONF network create \ - --label=demo1-net1 \ - --fixed_range_v4=12.0.0.0/24 \ - --project_id=$(get_tenant_id demo1) \ - --priority=1 - - $NOVA_MANAGE --flagfile=$NOVA_CONF network create \ - --label=demo2-net1 \ - --fixed_range_v4=13.0.0.0/24 \ - --project_id=$(get_tenant_id demo2) \ - --priority=1 -} - -function create_vms { - PUBLIC_NET1_ID=$(get_network_id public-net1) - DEMO1_NET1_ID=$(get_network_id demo1-net1) - DEMO2_NET1_ID=$(get_network_id demo2-net1) - - export OS_TENANT_NAME=demo1 - export OS_USERNAME=demo1 - export OS_PASSWORD=nova - VM_UUID1=`$NOVA boot --flavor $(get_flavor_id m1.tiny) \ - --image $(get_image_id) \ - --nic net-id=$PUBLIC_NET1_ID \ - --nic net-id=$DEMO1_NET1_ID \ - demo1-server1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'` - die_if_not_set VM_UUID1 "Failure launching demo1-server1" - - export OS_TENANT_NAME=demo2 - export OS_USERNAME=demo2 - export OS_PASSWORD=nova - VM_UUID2=`$NOVA boot --flavor $(get_flavor_id m1.tiny) \ - --image $(get_image_id) \ - --nic net-id=$PUBLIC_NET1_ID \ - --nic net-id=$DEMO2_NET1_ID \ - demo2-server1 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'` - die_if_not_set VM_UUID2 "Failure launching demo2-server1" - - VM_UUID3=`$NOVA boot --flavor $(get_flavor_id m1.tiny) \ - --image $(get_image_id) \ - --nic net-id=$PUBLIC_NET1_ID \ - --nic net-id=$DEMO2_NET1_ID \ - demo2-server2 | grep ' id ' | cut -d"|" -f3 | sed 's/ //g'` - die_if_not_set VM_UUID3 "Failure launching demo2-server2" - -} - -function ping_vms { - - echo "Sleeping a bit let the VMs come up" - sleep $ACTIVE_TIMEOUT - - export OS_TENANT_NAME=demo1 - export OS_USERNAME=demo1 - export OS_PASSWORD=nova - # get the IP of the servers - PUBLIC_IP1=`nova show $VM_UUID1 | grep public-net1 | awk '{print $5}'` - export OS_TENANT_NAME=demo2 - export OS_USERNAME=demo2 - export OS_PASSWORD=nova - PUBLIC_IP2=`nova show $VM_UUID2 | grep public-net1 | awk '{print $5}'` - - MULTI_HOST=`trueorfalse False $MULTI_HOST` - if [ "$MULTI_HOST" = "False" ]; then - # sometimes the first ping fails (10 seconds isn't enough time for the VM's - # network to respond?), so let's ping for a default of 15 seconds with a - # timeout of a second for each ping. - if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $PUBLIC_IP1; do sleep 1; done"; then - echo "Couldn't ping server" - exit 1 - fi - if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $PUBLIC_IP2; do sleep 1; done"; then - echo "Couldn't ping server" - exit 1 - fi - else - # On a multi-host system, without vm net access, do a sleep to wait for the boot - sleep $BOOT_TIMEOUT - fi -} - -function shutdown_vms { - export OS_TENANT_NAME=demo1 - export OS_USERNAME=demo1 - export OS_PASSWORD=nova - nova delete $VM_UUID1 - - export OS_TENANT_NAME=demo2 - export OS_USERNAME=demo2 - export OS_PASSWORD=nova - nova delete $VM_UUID2 - nova delete $VM_UUID3 - -} - -function delete_networks { - PUBLIC_NET1_ID=$(get_network_id public-net1) - DEMO1_NET1_ID=$(get_network_id demo1-net1) - DEMO2_NET1_ID=$(get_network_id demo2-net1) - nova-manage network delete --uuid=$PUBLIC_NET1_ID - nova-manage network delete --uuid=$DEMO1_NET1_ID - nova-manage network delete --uuid=$DEMO2_NET1_ID -} - -function all { - create_tenants - create_networks - create_vms - ping_vms - shutdown_vms - delete_networks - delete_tenants_and_users -} - -#------------------------------------------------------------------------------ -# Test functions. -#------------------------------------------------------------------------------ -function test_functions { - IMAGE=$(get_image_id) - echo $IMAGE - - TENANT_ID=$(get_tenant_id demo) - echo $TENANT_ID - - FLAVOR_ID=$(get_flavor_id m1.tiny) - echo $FLAVOR_ID - - NETWORK_ID=$(get_network_id private) - echo $NETWORK_ID -} - -#------------------------------------------------------------------------------ -# Usage and main. -#------------------------------------------------------------------------------ -usage() { - echo "$0: [-h]" - echo " -h, --help Display help message" - echo " -n, --net Create networks" - echo " -v, --vm Create vms" - echo " -t, --tenant Create tenants" - echo " -T, --test Test functions" -} - -main() { - if [ $# -eq 0 ] ; then - usage - exit - fi - - echo Description - echo - echo Copyright 2012, Cisco Systems - echo Copyright 2012, Nicira Networks, Inc. - echo - echo Please direct any questions to dedutta@cisco.com, dlapsley@nicira.com - echo - - while [ "$1" != "" ]; do - case $1 in - -h | --help ) usage - exit - ;; - -n | --net ) create_networks - exit - ;; - -v | --vm ) create_vms - exit - ;; - -t | --tenant ) create_tenants - exit - ;; - -p | --ping ) ping_vms - exit - ;; - -T | --test ) test_functions - exit - ;; - -a | --all ) all - exit - ;; - * ) usage - exit 1 - esac - shift - done -} - - -#------------------------------------------------------------------------------- -# Kick off script. -#------------------------------------------------------------------------------- -echo $* -main -a - -set +o xtrace -echo "*********************************************************************" -echo "SUCCESS: End DevStack Exercise: $0" -echo "*********************************************************************" diff --git a/stack.sh b/stack.sh index e6576e0391..dafff2b93b 100755 --- a/stack.sh +++ b/stack.sh @@ -269,7 +269,8 @@ Q_HOST=${Q_HOST:-localhost} Q_ADMIN_USERNAME=${Q_ADMIN_USERNAME:-quantum} # Default auth strategy Q_AUTH_STRATEGY=${Q_AUTH_STRATEGY:-keystone} - +# Use namespace or not +Q_USE_NAMESPACE=${Q_USE_NAMESPACE:-True} # Name of the lvm volume group to use/create for iscsi volumes VOLUME_GROUP=${VOLUME_GROUP:-stack-volumes} @@ -1204,6 +1205,7 @@ if is_service_enabled q-dhcp; then iniset $Q_DHCP_CONF_FILE DEFAULT verbose True # Set debug iniset $Q_DHCP_CONF_FILE DEFAULT debug True + iniset $Q_DHCP_CONF_FILE DEFAULT use_namespaces $Q_USE_NAMESPACE # Update database iniset $Q_DHCP_CONF_FILE DEFAULT db_connection "mysql:\/\/$MYSQL_USER:$MYSQL_PASSWORD@$MYSQL_HOST\/$Q_DB_NAME?charset=utf8"