Use flavor m1.tiny in healthcheck
authorjose.lausuch <jose.lausuch@ericsson.com>
Tue, 12 Jul 2016 11:25:10 +0000 (13:25 +0200)
committerjose.lausuch <jose.lausuch@ericsson.com>
Tue, 12 Jul 2016 12:39:37 +0000 (14:39 +0200)
In some small virtual environments, booting 4 VMs using the
flavor m1.small can fail because of insufficient disk space
or available hosts.
Check if the flavor exists, if it doesnt, create it.

Change-Id: Ib7a3f337ea5e0686bcb9af442be175db436e4e8a
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
testcases/OpenStack/healthcheck/healthcheck.sh

index 9fe1756..b890477 100755 (executable)
@@ -66,6 +66,7 @@ port_1="opnfv-port1"
 port_2="opnfv-port2"
 router_1="opnfv-router1"
 router_2="opnfv-router2"
+flavor="m1.tiny"
 instance_1="opnfv-instance1"
 instance_2="opnfv-instance2"
 instance_3="opnfv-instance3"
@@ -187,13 +188,23 @@ info "Testing Nova API..."
 # by SDN controller in case of odl_l2 scenario.
 sleep 60
 
-nova boot --flavor m1.small --image ${image_1} --nic net-id=${net1_id} ${instance_1}
+
+# Check if flavor exists
+if [[ -z $(nova flavor-list|grep $flavor) ]]; then
+    # if given flavor doesn't exist, we create one
+    debug "Flavor $flavor doesn't exist. Creating a new flavor."
+    nova flavor-create --is-public false ${flavor} auto 512 1 1 --is-public True
+fi
+debug "Using flavor $flavor to boot the instances."
+
+
+nova boot --flavor ${flavor} --image ${image_1} --nic net-id=${net1_id} ${instance_1}
 debug "nova instance '${instance_1}' booted on ${net_1}."
-nova boot --flavor m1.small --image ${image_1} --nic net-id=${net1_id} ${instance_2}
+nova boot --flavor ${flavor} --image ${image_1} --nic net-id=${net1_id} ${instance_2}
 debug "nova instance '${instance_2}' booted on ${net_1}."
-nova boot --flavor m1.small --image ${image_2} --nic net-id=${net2_id} ${instance_3}
+nova boot --flavor ${flavor} --image ${image_2} --nic net-id=${net2_id} ${instance_3}
 debug "nova instance '${instance_3}' booted on ${net_2}."
-nova boot --flavor m1.small --image ${image_2} --nic net-id=${net2_id} ${instance_4}
+nova boot --flavor ${flavor} --image ${image_2} --nic net-id=${net2_id} ${instance_4}
 debug "nova instance '${instance_4}' booted on ${net_2}."
 
 vm1_id=$(nova list | grep ${instance_1} | awk '{print $2}')