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/stackrc b/stackrc
index 3bbc475..bd4fe14 100644
--- a/stackrc
+++ b/stackrc
@@ -99,6 +99,17 @@
 MELANGECLIENT_REPO=${GIT_BASE}/openstack/python-melangeclient.git
 MELANGECLIENT_BRANCH=master
 
+# Nova hypervisor configuration.  We default to libvirt with **kvm** but will
+# drop back to **qemu** if we are unable to load the kvm module.  ``stack.sh`` can
+# also install an **LXC** or **OpenVZ** based system.
+VIRT_DRIVER=${VIRT_DRIVER:-libvirt}
+LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm}
+
+# allow local overrides of env variables
+if [ -f $RC_DIR/localrc ]; then
+    source $RC_DIR/localrc
+fi
+
 # Specify a comma-separated list of uec images to download and install into glance.
 # supported urls here are:
 #  * "uec-style" images:
@@ -114,19 +125,27 @@
 #      http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-rootfs.img.gz
 #IMAGE_URLS="http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-11.2_2.6.35-15_1.tar.gz" # old ttylinux-uec image
 #IMAGE_URLS="http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img" # cirros full disk image
-case "$LIBVIRT_TYPE" in
-    lxc) # the cirros root disk in the uec tarball is empty, so it will not work for lxc
-        DEFAULT_IMAGE_NAME=cirros-0.3.0-x86_64-rootfs
-        IMAGE_URLS="http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-rootfs.img.gz";;
-    *)  # otherwise, use the uec style image (with kernel, ramdisk, disk)
-        DEFAULT_IMAGE_NAME=cirros-0.3.0-x86_64-uec
-        IMAGE_URLS="http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-uec.tar.gz";;
+#
+# Set default image based on LIBVIRT_TYPE or VIRT_DRIVER, which may be set in localrc
+# but allow DEFAULT_IMAGE_NAME and IMAGE_URLS to be set directly in localrc, too.
+case "$VIRT_DRIVER" in
+    openvz) # OpenVZ uses its own format of image, and does not support uec style images
+        DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-ubuntu-11.10-x86_64}
+        IMAGE_URLS=${IMAGE_URLS:-"http://download.openvz.org/template/precreated/ubuntu-11.10-x86_64.tar.gz"};;
+    libvirt)
+        case "$LIBVIRT_TYPE" in
+            lxc) # the cirros root disk in the uec tarball is empty, so it will not work for lxc
+                DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.0-x86_64-rootfs}
+                IMAGE_URLS=${IMAGE_URLS:-"http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-rootfs.img.gz"};;
+            *) # otherwise, use the uec style image (with kernel, ramdisk, disk)
+                DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.0-x86_64-uec}
+                IMAGE_URLS=${IMAGE_URLS:-"http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-uec.tar.gz"};;
+        esac
+        ;;
+    *) # otherwise, use the uec style image (with kernel, ramdisk, disk)
+        DEFAULT_IMAGE_NAME=${DEFAULT_IMAGE_NAME:-cirros-0.3.0-x86_64-uec}
+        IMAGE_URLS=${IMAGE_URLS:-"http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-uec.tar.gz"};;
 esac
 
-# allow local overrides of env variables
-if [ -f $RC_DIR/localrc ]; then
-    source $RC_DIR/localrc
-fi
-
 # 5Gb default volume backing file size
 VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-5130M}