enable testing of openvz guests

This patch adds several options to allow using OpenVZ virt layer.
- modifies stack.sh and stackrc to recognize a new VIRT_TYPE option
- set IMAGE_URLS to an openvz image, if VIRT_TYPE == openvz

It also makes a few changes to some tests so that some implicit
defaults (such as the guest user account) can be overridden.

Change-Id: I0dde2dffbf3848fac1dd27eb37af84c0ac73d9aa
diff --git a/exercises/boot_from_volume.sh b/exercises/boot_from_volume.sh
index 6a0937a..7fe81ba 100755
--- a/exercises/boot_from_volume.sh
+++ b/exercises/boot_from_volume.sh
@@ -46,6 +46,8 @@
 # Default floating IP pool name
 DEFAULT_FLOATING_POOL=${DEFAULT_FLOATING_POOL:-nova}
 
+# Default user
+DEFAULT_INSTANCE_USER=${DEFAULT_INSTANCE_USER:-cirros}
 
 # Launching servers
 # =================
@@ -150,7 +152,7 @@
 # To do this, ssh to the builder instance, mount volume, and build a volume-backed image.
 STAGING_DIR=/tmp/stage
 CIRROS_DIR=/tmp/cirros
-ssh -o StrictHostKeyChecking=no -i $KEY_FILE cirros@$FLOATING_IP << EOF
+ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP << EOF
 set -o errexit
 set -o xtrace
 sudo mkdir -p $STAGING_DIR
@@ -168,10 +170,10 @@
 fi
 
 # Copy cirros onto the volume
-scp -o StrictHostKeyChecking=no -i $KEY_FILE cirros-0.3.0-x86_64-rootfs.img.gz cirros@$FLOATING_IP:$STAGING_DIR
+scp -o StrictHostKeyChecking=no -i $KEY_FILE cirros-0.3.0-x86_64-rootfs.img.gz ${DEFAULT_INSTANCE_USER}@$FLOATING_IP:$STAGING_DIR
 
 # Unpack cirros into volume
-ssh -o StrictHostKeyChecking=no -i $KEY_FILE cirros@$FLOATING_IP << EOF
+ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP << EOF
 set -o errexit
 set -o xtrace
 cd $STAGING_DIR
@@ -221,7 +223,7 @@
 fi
 
 # Make sure our volume-backed instance launched
-ssh -o StrictHostKeyChecking=no -i $KEY_FILE cirros@$FLOATING_IP << EOF
+ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP << EOF
 echo "success!"
 EOF
 
diff --git a/exercises/euca.sh b/exercises/euca.sh
index 4a538c6..9f7aed1 100755
--- a/exercises/euca.sh
+++ b/exercises/euca.sh
@@ -40,12 +40,15 @@
 # Instance type to create
 DEFAULT_INSTANCE_TYPE=${DEFAULT_INSTANCE_TYPE:-m1.tiny}
 
+# Boot this image, use first AMI-format image if unset
+DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ami}
+
 
 # Launching a server
 # ==================
 
 # Find a machine image to boot
-IMAGE=`euca-describe-images | grep machine | cut -f2 | head -n1`
+IMAGE=`euca-describe-images | grep machine | grep ${DEFAULT_IMAGE_NAME} | cut -f2 | head -n1`
 
 # Define secgroup
 SECGROUP=euca_secgroup
diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh
index 51019a3..02259c0 100755
--- a/exercises/floating_ips.sh
+++ b/exercises/floating_ips.sh
@@ -185,7 +185,7 @@
 nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 || die "Failure deleting security group rule from $SECGROUP"
 
 # FIXME (anthony): make xs support security groups
-if [ "$VIRT_DRIVER" != "xenserver" ]; then
+if [ "$VIRT_DRIVER" != "xenserver" -a "$VIRT_DRIVER" != "openvz" ]; then
     # test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds
     if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
         print "Security group failure - ping should not be allowed!"