Merge "Change MySQL engine default to InnoDB"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..68c771a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,176 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
diff --git a/exercises/boot_from_volume.sh b/exercises/boot_from_volume.sh
index c707b47..6a0937a 100755
--- a/exercises/boot_from_volume.sh
+++ b/exercises/boot_from_volume.sh
@@ -51,7 +51,7 @@
 # =================
 
 # Grab the id of the image to launch
-IMAGE=`glance -f index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
+IMAGE=`glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1`
 die_if_not_set IMAGE "Failure getting image"
 
 # Instance and volume names
diff --git a/exercises/client-args.sh b/exercises/client-args.sh
index 66fddcf..1d7d5b6 100755
--- a/exercises/client-args.sh
+++ b/exercises/client-args.sh
@@ -46,7 +46,9 @@
 
 # Common authentication args
 TENANT_ARG="--os_tenant_name=$x_TENANT_NAME"
+TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME"
 ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL"
+ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
 
 # Set global return
 RETURN=0
@@ -94,7 +96,7 @@
         STATUS_GLANCE="Skipped"
     else
         echo -e "\nTest Glance"
-        if glance $TENANT_ARG $ARGS index; then
+        if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then
             STATUS_GLANCE="Succeeded"
         else
             STATUS_GLANCE="Failed"
diff --git a/exercises/client-env.sh b/exercises/client-env.sh
index af2c4c2..10871a6 100755
--- a/exercises/client-env.sh
+++ b/exercises/client-env.sh
@@ -107,7 +107,7 @@
         STATUS_GLANCE="Skipped"
     else
         echo -e "\nTest Glance"
-        if glance index; then
+        if glance image-list; then
             STATUS_GLANCE="Succeeded"
         else
             STATUS_GLANCE="Failed"
diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh
index 9974b4b..dd40aa0 100755
--- a/exercises/floating_ips.sh
+++ b/exercises/floating_ips.sh
@@ -63,10 +63,10 @@
 nova image-list
 
 # But we recommend using glance directly
-glance -f index
+glance image-list
 
 # Grab the id of the image to launch
-IMAGE=`glance -f index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
+IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
 
 # Security Groups
 # ---------------
diff --git a/exercises/quantum.sh b/exercises/quantum.sh
new file mode 100755
index 0000000..943a07d
--- /dev/null
+++ b/exercises/quantum.sh
@@ -0,0 +1,393 @@
+#!/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.
+#------------------------------------------------------------------------------
+NOVA_MANAGE=/opt/stack/nova/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 -f -A $TOKEN index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
+    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=${MULTI_HOST:-0}
+    if [ "$MULTI_HOST" = "0" ]; 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/exercises/sec_groups.sh b/exercises/sec_groups.sh
new file mode 100755
index 0000000..49cb58f
--- /dev/null
+++ b/exercises/sec_groups.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+# **sec_groups.sh**
+
+# Test security groups via the command line tools that ship with it.
+
+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
+
+
+# Settings
+# ========
+
+# 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
+
+
+# Testing Security Groups
+# =============
+
+# List security groups
+nova secgroup-list
+
+# Create random name for new sec group and create secgroup of said name
+SEC_GROUP_NAME="sec-group-$(openssl rand -hex 4)"
+nova secgroup-create $SEC_GROUP_NAME 'a test security group'
+
+# Add some rules to the secgroup
+RULES_TO_ADD=( 22 3389 5900 )
+
+for RULE in "${RULES_TO_ADD[@]}"; do
+    nova secgroup-add-rule $SEC_GROUP_NAME tcp $RULE $RULE 0.0.0.0/00
+done
+
+# Check to make sure rules were added
+SEC_GROUP_RULES=( $(nova secgroup-list-rules $SEC_GROUP_NAME | grep -v \- | grep -v 'Source Group' | cut -d '|' -f3 | tr -d ' ') )
+for i in "${RULES_TO_ADD[@]}"; do
+    skip=
+    for j in "${SEC_GROUP_RULES[@]}"; do
+        [[ $i == $j ]] && { skip=1; break; }
+    done
+    [[ -n $skip ]] || exit 1
+done
+
+# Delete rules and secgroup
+for RULE in "${RULES_TO_ADD[@]}"; do
+    nova secgroup-delete-rule $SEC_GROUP_NAME tcp $RULE $RULE 0.0.0.0/00
+done
+nova secgroup-delete $SEC_GROUP_NAME
+
+
+set +o xtrace
+echo "*********************************************************************"
+echo "SUCCESS: End DevStack Exercise: $0"
+echo "*********************************************************************"
diff --git a/exercises/volumes.sh b/exercises/volumes.sh
index 1abbecc..b62427f 100755
--- a/exercises/volumes.sh
+++ b/exercises/volumes.sh
@@ -53,10 +53,10 @@
 nova image-list
 
 # But we recommend using glance directly
-glance -f index
+glance image-list
 
 # Grab the id of the image to launch
-IMAGE=`glance -f index | egrep $DEFAULT_IMAGE_NAME | head -1 | cut -d" " -f1`
+IMAGE=$(glance image-list | egrep " $DEFAULT_IMAGE_NAME " | get_field 1)
 
 # determinine instance type
 # -------------------------
diff --git a/files/apts/glance b/files/apts/glance
index 42d9fb8..a05e9f2 100644
--- a/files/apts/glance
+++ b/files/apts/glance
@@ -1,4 +1,6 @@
 gcc
+libxml2-dev
+python-dev
 python-eventlet
 python-routes
 python-greenlet
diff --git a/files/apts/n-api b/files/apts/n-api
index 0f08daa..ad943ff 100644
--- a/files/apts/n-api
+++ b/files/apts/n-api
@@ -1 +1,2 @@
+gcc  # temporary because this pulls in glance to get the client without running the glance prereqs
 python-dateutil
diff --git a/files/default_catalog.templates b/files/default_catalog.templates
index 31618ab..66052b6 100644
--- a/files/default_catalog.templates
+++ b/files/default_catalog.templates
@@ -30,7 +30,7 @@
 catalog.RegionOne.s3.name = S3 Service
 
 
-catalog.RegionOne.image.publicURL = http://%SERVICE_HOST%:9292/v1
-catalog.RegionOne.image.adminURL = http://%SERVICE_HOST%:9292/v1
-catalog.RegionOne.image.internalURL = http://%SERVICE_HOST%:9292/v1
+catalog.RegionOne.image.publicURL = http://%SERVICE_HOST%:9292
+catalog.RegionOne.image.adminURL = http://%SERVICE_HOST%:9292
+catalog.RegionOne.image.internalURL = http://%SERVICE_HOST%:9292
 catalog.RegionOne.image.name = Image Service
diff --git a/files/pips/tempest b/files/pips/tempest
index df7f423..6eeb5b9 100644
--- a/files/pips/tempest
+++ b/files/pips/tempest
@@ -1 +1,2 @@
 pika
+nosexunit  # For use by jenkins in producing reports
diff --git a/files/rpms/glance b/files/rpms/glance
index 141fe97..e38f239 100644
--- a/files/rpms/glance
+++ b/files/rpms/glance
@@ -1,3 +1,4 @@
+libxml2-devel
 python-argparse
 python-eventlet
 python-greenlet
diff --git a/stack.sh b/stack.sh
index 7ec4ee4..71c5ffc 100755
--- a/stack.sh
+++ b/stack.sh
@@ -201,6 +201,7 @@
 NOVA_DIR=$DEST/nova
 HORIZON_DIR=$DEST/horizon
 GLANCE_DIR=$DEST/glance
+GLANCECLIENT_DIR=$DEST/python-glanceclient
 KEYSTONE_DIR=$DEST/keystone
 NOVACLIENT_DIR=$DEST/python-novaclient
 KEYSTONECLIENT_DIR=$DEST/python-keystoneclient
@@ -313,7 +314,7 @@
 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
     PUBLIC_INTERFACE_DEFAULT=eth3
     # allow build_domU.sh to specify the flat network bridge via kernel args
-    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[^.]*' /proc/cmdline | cut -d= -f 2)
+    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u)
     GUEST_INTERFACE_DEFAULT=eth1
 else
     PUBLIC_INTERFACE_DEFAULT=br100
@@ -643,6 +644,7 @@
 # python client library to nova that horizon (and others) use
 git_clone $KEYSTONECLIENT_REPO $KEYSTONECLIENT_DIR $KEYSTONECLIENT_BRANCH
 git_clone $NOVACLIENT_REPO $NOVACLIENT_DIR $NOVACLIENT_BRANCH
+git_clone $GLANCECLIENT_REPO $GLANCECLIENT_DIR $GLANCECLIENT_BRANCH
 
 # glance, swift middleware and nova api needs keystone middleware
 if is_service_enabled key g-api n-api swift; then
@@ -715,6 +717,9 @@
     cd $MELANGECLIENT_DIR; sudo python setup.py develop
 fi
 
+# Do this _after_ glance is installed to override the old binary
+cd $GLANCECLIENT_DIR; sudo python setup.py develop
+
 
 # Syslog
 # ------
@@ -1671,7 +1676,6 @@
     # Rewrite stock keystone.conf:
     iniset $KEYSTONE_CONF DEFAULT admin_token "$SERVICE_TOKEN"
     iniset $KEYSTONE_CONF sql connection "$BASE_SQL_CONN/keystone?charset=utf8"
-    iniset $KEYSTONE_CONF catalog template_file "$KEYSTONE_CATALOG"
     iniset $KEYSTONE_CONF ec2 driver "keystone.contrib.ec2.backends.sql.Ec2"
     # Configure keystone.conf to use templates
     iniset $KEYSTONE_CONF catalog driver "keystone.catalog.backends.templated.TemplatedCatalog"
@@ -1867,21 +1871,19 @@
         esac
 
         if [ "$CONTAINER_FORMAT" = "bare" ]; then
-            glance add --silent-upload -A $TOKEN name="$IMAGE_NAME" is_public=true container_format=$CONTAINER_FORMAT disk_format=$DISK_FORMAT < <(zcat --force "${IMAGE}")
+            glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME" --public --container-format=$CONTAINER_FORMAT --disk-format $DISK_FORMAT < <(zcat --force "${IMAGE}")
         else
             # Use glance client to add the kernel the root filesystem.
             # We parse the results of the first upload to get the glance ID of the
             # kernel for use when uploading the root filesystem.
             KERNEL_ID=""; RAMDISK_ID="";
             if [ -n "$KERNEL" ]; then
-                RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-kernel" is_public=true container_format=aki disk_format=aki < "$KERNEL"`
-                KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
+                KERNEL_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-kernel" --public --container-format aki --disk-format aki < "$KERNEL" | grep ' id ' | get_field 2)
             fi
             if [ -n "$RAMDISK" ]; then
-                RVAL=`glance add --silent-upload -A $TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"`
-                RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
+                RAMDISK_ID=$(glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "$IMAGE_NAME-ramdisk" --public --container-format ari --disk-format ari < "$RAMDISK" | grep ' id ' | get_field 2)
             fi
-            glance add -A $TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat --force "${IMAGE}")
+            glance --os-auth-token $TOKEN --os-image-url http://$GLANCE_HOSTPORT image-create --name "${IMAGE_NAME%.img}" --public --container-format ami --disk-format ami ${KERNEL_ID:+--property kernel_id=$KERNEL_ID} ${RAMDISK_ID:+--property ramdisk_id=$RAMDISK_ID} < "${IMAGE}"
         fi
     done
 fi
diff --git a/stackrc b/stackrc
index d0fa1c2..3ad46cc 100644
--- a/stackrc
+++ b/stackrc
@@ -17,14 +17,14 @@
 SWIFT_REPO=https://github.com/openstack/swift.git
 SWIFT_BRANCH=master
 
-# swift and keystone integration
-SWIFT_KEYSTONE_REPO=https://github.com/cloudbuilders/swift-keystone2.git
-SWIFT_KEYSTONE_BRANCH=master
-
 # image catalog service
 GLANCE_REPO=https://github.com/openstack/glance.git
 GLANCE_BRANCH=master
 
+# python glance client library
+GLANCECLIENT_REPO=https://github.com/openstack/python-glanceclient
+GLANCECLIENT_BRANCH=master
+
 # unified auth system (manages accounts/tokens)
 KEYSTONE_REPO=https://github.com/openstack/keystone.git
 KEYSTONE_BRANCH=master
diff --git a/tools/configure_tempest.sh b/tools/configure_tempest.sh
index 01849ad..bed3d67 100755
--- a/tools/configure_tempest.sh
+++ b/tools/configure_tempest.sh
@@ -2,10 +2,22 @@
 #
 # configure_tempest.sh - Build a tempest configuration file from devstack
 
+echo "**************************************************"
+echo "Configuring Tempest"
+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
+
 function usage {
     echo "$0 - Build tempest.conf"
     echo ""
-    echo "Usage: $0 [configdir]"
+    echo "Usage: $0"
     exit 1
 }
 
@@ -13,21 +25,6 @@
     usage
 fi
 
-# Clean up any resources that may be in use
-cleanup() {
-    set +o errexit
-
-    # Mop up temporary files
-    if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then
-        rm -f $CONFIG_INI_TMP
-    fi
-
-    # Kill ourselves to signal any calling process
-    trap 2; kill -2 $$
-}
-
-trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
-
 # Keep track of the current directory
 TOOLS_DIR=$(cd $(dirname "$0") && pwd)
 TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
@@ -37,44 +34,26 @@
 
 # Abort if localrc is not set
 if [ ! -e $TOP_DIR/localrc ]; then
-    echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
-    echo "See stack.sh for required passwords."
+    echo "You must have a localrc with necessary basic configuration defined before proceeding."
+    exit 1
+fi
+
+# Abort if openrc is not set
+if [ ! -e $TOP_DIR/openrc ]; then
+    echo "You must have an openrc with ALL necessary passwords and credentials defined before proceeding."
     exit 1
 fi
 
 # Source params
-source ./stackrc
-
-# Set defaults not configured by stackrc
-TENANT=${TENANT:-admin}
-USERNAME=${USERNAME:-admin}
-IDENTITY_HOST=${IDENTITY_HOST:-$HOST_IP}
-IDENTITY_PORT=${IDENTITY_PORT:-5000}
-IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0}
+source $TOP_DIR/openrc
 
 # Where Openstack code lives
 DEST=${DEST:-/opt/stack}
 
 TEMPEST_DIR=$DEST/tempest
-
-CONFIG_DIR=${1:-$TEMPEST_DIR/etc}
-CONFIG_INI=$CONFIG_DIR/config.ini
+CONFIG_DIR=$TEMPEST_DIR/etc
 TEMPEST_CONF=$CONFIG_DIR/tempest.conf
 
-if [ ! -f $DEST/.ramdisk ]; then
-    # Process network configuration vars
-    GUEST_NETWORK=${GUEST_NETWORK:-1}
-    GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
-
-    GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
-    GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
-    GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
-    GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
-    GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
-    GUEST_RAM=${GUEST_RAM:-1524288}
-    GUEST_CORES=${GUEST_CORES:-1}
-fi
-
 # Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
 HOST_IP=${HOST_IP:-$GUEST_IP}
 # Use the first IP if HOST_IP still is not set
@@ -82,58 +61,42 @@
     HOST_IP=`LC_ALL=C /sbin/ifconfig  | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
 fi
 
-RABBIT_HOST=${RABBIT_HOST:-localhost}
-
-# Glance connection info.  Note the port must be specified.
-GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
-set `echo $GLANCE_HOSTPORT | tr ':' ' '`
-GLANCE_HOST=$1
-GLANCE_PORT=$2
-
-# Set up downloaded images
-# Defaults to use first image
-
-IMAGE_DIR=""
-IMAGE_NAME=""
-for imagedir in $TOP_DIR/files/images/*; do
-    KERNEL=""
-    RAMDISK=""
-    IMAGE=""
-    IMAGE_RAMDISK=""
-    KERNEL=$(for f in "$imagedir/"*-vmlinuz*; do
-        [ -f "$f" ] && echo "$f" && break; done; true)
-    [ -n "$KERNEL" ] && ln -sf $KERNEL $imagedir/kernel
-    RAMDISK=$(for f in "$imagedir/"*-initrd*; do
-        [ -f "$f" ] && echo "$f" && break; done; true)
-    [ -n "$RAMDISK" ] && ln -sf $RAMDISK $imagedir/ramdisk && \
-                         IMAGE_RAMDISK="ari_location = $imagedir/ramdisk"
-    IMAGE=$(for f in "$imagedir/"*.img; do
-        [ -f "$f" ] && echo "$f" && break; done; true)
-    if [ -n "$IMAGE" ]; then
-        ln -sf $IMAGE $imagedir/disk
-        # Save the first image directory that contains a disk image link
-        if [ -z "$IMAGE_DIR" ]; then
-            IMAGE_DIR=$imagedir
-            IMAGE_NAME=$(basename ${IMAGE%.img})
-        fi
-    fi
+# Glance should already contain images to be used in tempest
+# testing. Here we simply look for images stored in Glance
+# and set the appropriate variables for use in the tempest config
+# We ignore ramdisk and kernel images and set the IMAGE_UUID to
+# the first image returned and set IMAGE_UUID_ALT to the second,
+# if there is more than one returned...
+IMAGE_LINES=`glance image-list`
+IFS="$(echo -e "\n\r")"
+IMAGES=""
+for line in $IMAGE_LINES; do
+    IMAGES="$IMAGES `echo $line | grep -v "^\(ID\|+--\)" | grep -v "\(aki\|ari\)" | cut -d' ' -f2`"
 done
-if [[ -n "$IMAGE_NAME" ]]; then
-    # Get the image UUID
-    IMAGE_UUID=$(nova image-list | grep " $IMAGE_NAME " | cut -d'|' -f2)
-    # Strip spaces off
-    IMAGE_UUID=$(echo $IMAGE_UUID)
+# Create array of image UUIDs...
+IFS=" "
+IMAGES=($IMAGES)
+NUM_IMAGES=${#IMAGES[*]}
+echo "Found $NUM_IMAGES images"
+if [[ $NUM_IMAGES -eq 0 ]]; then
+    echo "Found no valid images to use!"
+    exit 1
+fi
+IMAGE_UUID=${IMAGES[0]}
+IMAGE_UUID_ALT=$IMAGE_UUID
+if [[ $NUM_IMAGES -gt 1 ]]; then
+    IMAGE_UUID_ALT=${IMAGES[1]}
 fi
 
 # Create tempest.conf from tempest.conf.tpl
-
 if [[ ! -r $TEMPEST_CONF ]]; then
     cp $TEMPEST_CONF.tpl $TEMPEST_CONF
 fi
 
 IDENTITY_USE_SSL=${IDENTITY_USE_SSL:-False}
+IDENTITY_HOST=${IDENTITY_HOST:-127.0.0.1}
 IDENTITY_PORT=${IDENTITY_PORT:-5000}
-IDENTITY_API_VERSION={$IDENTITY_API_VERSION:-v2.0} # Note: need v for now...
+IDENTITY_API_VERSION="v2.0" # Note: need v for now...
 # TODO(jaypipes): This is dumb and needs to be removed
 # from the Tempest configuration file entirely...
 IDENTITY_PATH=${IDENTITY_PATH:-tokens}
@@ -152,27 +115,30 @@
 ALT_PASSWORD=$OS_PASSWORD
 ALT_TENANT_NAME=$OS_TENANT_NAME
 
-# TODO(jaypipes): Support multiple images instead of plopping
-# the IMAGE_UUID into both the image_ref and image_ref_alt slots
-IMAGE_UUID_ALT=$IMAGE_UUID
-
 # TODO(jaypipes): Support configurable flavor refs here...
 FLAVOR_REF=1
 FLAVOR_REF_ALT=2
 
-ADMIN_USERNAME={$ADMIN_USERNAME:-admin}
-ADMIN_PASSWORD={$ADMIN_PASSWORD:-secrete}
-ADMIN_TENANT_NAME={$ADMIN_TENANT:-admin}
+ADMIN_USERNAME=${ADMIN_USERNAME:-admin}
+ADMIN_PASSWORD=${ADMIN_PASSWORD:-secrete}
+ADMIN_TENANT_NAME=${ADMIN_TENANT:-admin}
 
 # Do any of the following need to be configurable?
 COMPUTE_CATALOG_TYPE=compute
 COMPUTE_CREATE_IMAGE_ENABLED=True
-COMPUTE_RESIZE_AVAILABLE=True
+COMPUTE_RESIZE_AVAILABLE=False  # not supported with QEMU...
 COMPUTE_LOG_LEVEL=ERROR
+BUILD_INTERVAL=10
+BUILD_TIMEOUT=600
+
+# Image test configuration options...
+IMAGE_HOST=${IMAGE_HOST:-127.0.0.1}
+IMAGE_PORT=${IMAGE_PORT:-9292}
+IMAGE_API_VERSION="1"
 
 sed -e "
     s,%IDENTITY_USE_SSL%,$IDENTITY_USE_SSL,g;
-    s,%IDENTITY_HOST%,$HOST_IP,g;
+    s,%IDENTITY_HOST%,$IDENTITY_HOST,g;
     s,%IDENTITY_PORT%,$IDENTITY_PORT,g;
     s,%IDENTITY_API_VERSION%,$IDENTITY_API_VERSION,g;
     s,%IDENTITY_PATH%,$IDENTITY_PATH,g;
@@ -187,97 +153,24 @@
     s,%COMPUTE_CREATE_IMAGE_ENABLED%,$COMPUTE_CREATE_IMAGE_ENABLED,g;
     s,%COMPUTE_RESIZE_AVAILABLE%,$COMPUTE_RESIZE_AVAILABLE,g;
     s,%COMPUTE_LOG_LEVEL%,$COMPUTE_LOG_LEVEL,g;
+    s,%BUILD_INTERVAL%,$BUILD_INTERVAL,g;
+    s,%BUILD_TIMEOUT%,$BUILD_TIMEOUT,g;
     s,%IMAGE_ID%,$IMAGE_UUID,g;
     s,%IMAGE_ID_ALT%,$IMAGE_UUID_ALT,g;
     s,%FLAVOR_REF%,$FLAVOR_REF,g;
     s,%FLAVOR_REF_ALT%,$FLAVOR_REF_ALT,g;
+    s,%IMAGE_HOST%,$IMAGE_HOST,g;
+    s,%IMAGE_PORT%,$IMAGE_PORT,g;
+    s,%IMAGE_API_VERSION%,$IMAGE_API_VERSION,g;
     s,%ADMIN_USERNAME%,$ADMIN_USERNAME,g;
     s,%ADMIN_PASSWORD%,$ADMIN_PASSWORD,g;
     s,%ADMIN_TENANT_NAME%,$ADMIN_TENANT_NAME,g;
 " -i $TEMPEST_CONF
 
-# Create config.ini
+echo "Created tempest configuration file:"
+cat $TEMPEST_CONF
 
-CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
-if [ "$UPLOAD_LEGACY_TTY" ]; then
-    cat >$CONFIG_INI_TMP <<EOF
-[environment]
-aki_location = $TOP_DIR/files/images/aki-tty/image
-ari_location = $TOP_DIR/files/images/ari-tty/image
-ami_location = $TOP_DIR/files/images/ami-tty/image
-image_ref = 3
-image_ref_alt = 3
-flavor_ref = 1
-flavor_ref_alt = 2
-
-[glance]
-host = $GLANCE_HOST
-apiver = v1
-port = $GLANCE_PORT
-image_id = 3
-image_id_alt = 3
-tenant_id = 1
-EOF
-else
-    cat >$CONFIG_INI_TMP <<EOF
-[environment]
-aki_location = $IMAGE_DIR/kernel
-ami_location = $IMAGE_DIR/disk
-$IMAGE_RAMDISK
-image_ref = 2
-image_ref_alt = 2
-flavor_ref = 1
-flavor_ref_alt = 2
-
-[glance]
-host = $GLANCE_HOST
-apiver = v1
-port = $GLANCE_PORT
-image_id = 2
-image_id_alt = 2
-tenant_id = 1
-EOF
-fi
-
-cat >>$CONFIG_INI_TMP <<EOF
-
-[keystone]
-service_host = $HOST_IP
-service_port = 5000
-apiver = v2.0
-user = admin
-password = $ADMIN_PASSWORD
-tenant_name = admin
-
-[nova]
-host = $HOST_IP
-port = 8774
-apiver = v1.1
-project = admin
-user = admin
-key = $ADMIN_PASSWORD
-ssh_timeout = 300
-build_timeout = 300
-flavor_ref = 1
-flavor_ref_alt = 2
-multi_node = no
-
-[rabbitmq]
-host = $RABBIT_HOST
-user = guest
-password = $RABBIT_PASSWORD
-
-[swift]
-auth_host = $HOST_IP
-auth_port = 443
-auth_prefix = /auth/
-auth_ssl = yes
-account = system
-username = root
-password = password
-
-EOF
-mv $CONFIG_INI_TMP $CONFIG_INI
-CONFIG_INI_TMP=""
-
-trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT
+echo "\n"
+echo "**************************************************"
+echo "Finished Configuring Tempest"
+echo "**************************************************"
diff --git a/tools/xen/README.md b/tools/xen/README.md
index d487a99..d102b01 100644
--- a/tools/xen/README.md
+++ b/tools/xen/README.md
@@ -1,7 +1,7 @@
 Getting Started With XenServer 5.6 and Devstack
 ===============================================
 The purpose of the code in this directory it to help developers bootstrap
-a XenServer 5.6 + Openstack development environment.  This file gives
+a XenServer 5.6 (or greater) + Openstack development environment.  This file gives
 some pointers on how to get started.
 
 Xenserver is a Type 1 hypervisor, so it needs to be installed on bare metal.
@@ -25,36 +25,25 @@
 * XenServer Gateway: 192.168.1.1
 * XenServer DNS: 192.168.1.1
 
-Note:
-------
-It is advisable (and necessary if you are using Xenserver 6.0, due to space
-limitations), to create the above mentioned OS domU, on a separate dev machine.
-To do this, you will need to run Steps 2 on the dev machine (if required) as
-well as the Xenserver host. Steps 3 and 4 should be run on the dev machine.
-This process requires you to be root on the dev machine.
+Step 2: Download devstack
+--------------------------
+On your XenServer host, run the following commands as root:
 
-Step 2: Prepare DOM0
--------------------
-At this point, your host is missing some critical software that you will
-need to run devstack (like git).  Do this to install required software:
+wget --no-check-certificate https://github.com/openstack-dev/devstack/zipball/master
+unzip -o master -d ./devstack
+cd devstack/*/
 
-    wget --no-check-certificate https://raw.github.com/openstack-dev/devstack/master/tools/xen/prepare_dom0.sh
-    chmod 755 prepare_dom0.sh
-    ./prepare_dom0.sh
-
-This step will also clone devstack in $DEVSTACKSRCROOT/devstack.
-$DEVSTACKSRCROOT=/root by default.
-
-Step 3: Configure your localrc
------------------------------
+Step 3: Configure your localrc inside the devstack directory
+------------------------------------------------------------
 Devstack uses a localrc for user-specific configuration.  Note that
 the XENAPI_PASSWORD must be your dom0 root password.
 Of course, use real passwords if this machine is exposed.
 
-    cat > $DEVSTACKSRCROOT/devstack/localrc <<EOF
+    cat > ./localrc <<EOF
     MYSQL_PASSWORD=my_super_secret
     SERVICE_TOKEN=my_super_secret
     ADMIN_PASSWORD=my_super_secret
+    SERVICE_PASSWORD=$ADMIN_PASSWORD
     RABBIT_PASSWORD=my_super_secret
     # This is the password for your guest (for both stack and root users)
     GUEST_PASSWORD=my_super_secret
@@ -70,32 +59,24 @@
     ACTIVE_TIMEOUT=45
     # Interface on which you would like to access services
     HOST_IP_IFACE=ethX
+    # First time Ubuntu network install params
+    NETINSTALLIP="dhcp"
+    NAMESERVERS=""
+    NETMASK=""
+    GATEWAY=""
     EOF
 
-Step 4: Run ./build_xva.sh
---------------------------
-This script prepares your nova xva image. If you run this on a different machine,
-copy the resulting xva file to tools/xen/xvas/[GUEST_NAME].xva
-(by default tools/xen/xvas/ALLINONE.xva) on the Xenserver host.
+Step 4: Run ./install_os_domU.sh from the tools/xen directory
+-------------------------------------------------------------
+cd tools/xen
+./install_os_domU.sh
 
-cd $DEVSTACKSRCROOT/devstack/tools/xen
-./build_xva.sh
+Once this script finishes executing, log into the VM (openstack domU)
+that it installed and tail the run.sh.log file. You will need to wait
+until it run.sh has finished executing.
 
-You will also need to copy your localrc to the Xenserver host.
 
-Step 5: Run ./build_domU.sh
---------------------------
-This script does a lot of stuff, it is probably best to read it in its entirety.
-But in a nutshell, it performs the following:
-
-* Configures bridges and vlans for public, private, and management nets
-* Creates and installs a OpenStack all-in-one domU in an HA-FlatDHCP configuration
-* A script to create a multi-domU (ie. head node separated from compute) configuration is coming soon!
-
-cd $DEVSTACKSRCROOT/devstack/tools/xen
-./build_domU.sh
-
-Step 6: Do cloudy stuff!
+Step 5: Do cloudy stuff!
 --------------------------
 * Play with horizon
 * Play with the CLI
diff --git a/tools/xen/build_xva.sh b/tools/xen/build_xva.sh
index c235485..edc0db3 100755
--- a/tools/xen/build_xva.sh
+++ b/tools/xen/build_xva.sh
@@ -1,5 +1,27 @@
 #!/bin/bash
 
+set -e
+
+declare -a on_exit_hooks
+
+on_exit()
+{
+    for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0)
+    do
+        eval "${on_exit_hooks[$i]}"
+    done
+}
+
+add_on_exit()
+{
+    local n=${#on_exit_hooks[*]}
+    on_exit_hooks[$n]="$*"
+    if [[ $n -eq 0 ]]
+    then
+        trap on_exit EXIT
+    fi
+}
+
 # Abort if localrc is not set
 if [ ! -e ../../localrc ]; then
     echo "You must have a localrc with ALL necessary passwords defined before proceeding."
@@ -16,27 +38,11 @@
 # Echo commands
 set -o xtrace
 
+GUEST_NAME="$1"
+
 # Directory where we stage the build
-STAGING_DIR=$TOP_DIR/stage
-
-# Option to clean out old stuff
-CLEAN=${CLEAN:-0}
-if [ "$CLEAN" = "1" ]; then
-    rm -rf $STAGING_DIR
-fi
-
-# Download our base image.  This image is made using prepare_guest.sh
-BASE_IMAGE_URL=${BASE_IMAGE_URL:-http://images.ansolabs.com/xen/stage.tgz}
-if [ ! -e $STAGING_DIR ]; then
-    if [ ! -e /tmp/stage.tgz ]; then
-        wget $BASE_IMAGE_URL -O /tmp/stage.tgz
-    fi
-    tar xfz /tmp/stage.tgz
-    cd $TOP_DIR
-fi
-
-# Free up precious disk space
-rm -f /tmp/stage.tgz
+STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
+add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
 
 # Make sure we have a stage
 if [ ! -d $STAGING_DIR/etc ]; then
@@ -55,63 +61,26 @@
 UBUNTU_VERSION=`cat $STAGING_DIR/etc/lsb-release | grep "DISTRIB_CODENAME=" | sed "s/DISTRIB_CODENAME=//"`
 KERNEL_VERSION=`ls $STAGING_DIR/boot/vmlinuz* | head -1 | sed "s/.*vmlinuz-//"`
 
-# Directory for xvas
-XVA_DIR=$TOP_DIR/xvas
-
-# Create xva dir
-mkdir -p $XVA_DIR
-
-# Path to xva
-XVA=$XVA_DIR/$GUEST_NAME.xva
-
-# Setup fake grub
-rm -rf $STAGING_DIR/boot/grub/
-mkdir -p $STAGING_DIR/boot/grub/
-cp $TEMPLATES_DIR/menu.lst.in $STAGING_DIR/boot/grub/menu.lst
-sed -e "s,@KERNEL_VERSION@,$KERNEL_VERSION,g" -i $STAGING_DIR/boot/grub/menu.lst
-
-# Setup fstab, tty, and other system stuff
-cp $FILES_DIR/fstab $STAGING_DIR/etc/fstab
-cp $FILES_DIR/hvc0.conf $STAGING_DIR/etc/init/
-
-# Put the VPX into UTC.
-rm -f $STAGING_DIR/etc/localtime
-
 # Configure dns (use same dns as dom0)
 cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
 
 # Copy over devstack
 rm -f /tmp/devstack.tar
-tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar $TOP_DIR/../../../devstack
-cd $STAGING_DIR/opt/stack/
-tar xf /tmp/devstack.tar
+cd $TOP_DIR/../../
+tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar .
+mkdir -p $STAGING_DIR/opt/stack/devstack
+tar xf /tmp/devstack.tar -C $STAGING_DIR/opt/stack/devstack
 cd $TOP_DIR
 
-# Configure OVA
-VDI_SIZE=$(($VDI_MB*1024*1024))
-PRODUCT_BRAND=${PRODUCT_BRAND:-openstack}
-PRODUCT_VERSION=${PRODUCT_VERSION:-001}
-BUILD_NUMBER=${BUILD_NUMBER:-001}
-LABEL="$PRODUCT_BRAND $PRODUCT_VERSION-$BUILD_NUMBER"
-OVA=$STAGING_DIR/tmp/ova.xml
-cp $TEMPLATES_DIR/ova.xml.in  $OVA
-sed -e "s,@VDI_SIZE@,$VDI_SIZE,g" -i $OVA
-sed -e "s,@PRODUCT_BRAND@,$PRODUCT_BRAND,g" -i $OVA
-sed -e "s,@PRODUCT_VERSION@,$PRODUCT_VERSION,g" -i $OVA
-sed -e "s,@BUILD_NUMBER@,$BUILD_NUMBER,g" -i $OVA
-
 # Run devstack on launch
 cat <<EOF >$STAGING_DIR/etc/rc.local
 # network restart required for getting the right gateway
 /etc/init.d/networking restart
 GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1
-su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" stack
+su -c "/opt/stack/run.sh > /opt/stack/run.sh.log 2>&1" stack
 exit 0
 EOF
 
-# Clean old xva. In the future may not do this every time.
-rm -f $XVA
-
 # Configure the hostname
 echo $GUEST_NAME > $STAGING_DIR/etc/hostname
 
@@ -151,10 +120,6 @@
     sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
 fi
 
-if [ -h $STAGING_DIR/sbin/dhclient3 ]; then
-    rm -f $STAGING_DIR/sbin/dhclient3
-fi
-
 # Gracefully cp only if source file/dir exists
 function cp_it {
     if [ -e $1 ] || [ -d $1 ]; then
@@ -177,15 +142,8 @@
 #!/bin/bash
 cd /opt/stack/devstack
 killall screen
-UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=1 HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh
+UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=$MULTI_HOST HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh
 EOF
 chmod 755 $STAGING_DIR/opt/stack/run.sh
 
-# Create xva
-if [ ! -e $XVA ]; then
-    rm -rf /tmp/mkxva*
-    UID=0 $SCRIPT_DIR/mkxva -o $XVA -t xva -x $OVA $STAGING_DIR $VDI_MB /tmp/
-fi
-
-echo "Built $(basename $XVA).  If your dom0 is on a different machine, copy this to [devstackdir]/tools/xen/$(basename $XVA)"
-echo "Also copy your localrc to [devstackdir]"
+echo "Done"
diff --git a/tools/xen/devstackubuntupreseed.cfg b/tools/xen/devstackubuntupreseed.cfg
new file mode 100644
index 0000000..d8caaee
--- /dev/null
+++ b/tools/xen/devstackubuntupreseed.cfg
@@ -0,0 +1,470 @@
+### Contents of the preconfiguration file (for squeeze)
+### Localization
+# Preseeding only locale sets language, country and locale.
+d-i debian-installer/locale string en_US
+
+# The values can also be preseeded individually for greater flexibility.
+#d-i debian-installer/language string en
+#d-i debian-installer/country string NL
+#d-i debian-installer/locale string en_GB.UTF-8
+# Optionally specify additional locales to be generated.
+#d-i localechooser/supported-locales en_US.UTF-8, nl_NL.UTF-8
+
+# Keyboard selection.
+# Disable automatic (interactive) keymap detection.
+d-i console-setup/ask_detect boolean false
+#d-i keyboard-configuration/modelcode string pc105
+d-i keyboard-configuration/layoutcode string us
+# To select a variant of the selected layout (if you leave this out, the
+# basic form of the layout will be used):
+#d-i keyboard-configuration/variantcode string dvorak
+
+### Network configuration
+# Disable network configuration entirely. This is useful for cdrom
+# installations on non-networked devices where the network questions,
+# warning and long timeouts are a nuisance.
+#d-i netcfg/enable boolean false
+
+# netcfg will choose an interface that has link if possible. This makes it
+# skip displaying a list if there is more than one interface.
+d-i netcfg/choose_interface select auto
+
+# To pick a particular interface instead:
+#d-i netcfg/choose_interface select eth1
+
+# If you have a slow dhcp server and the installer times out waiting for
+# it, this might be useful.
+#d-i netcfg/dhcp_timeout string 60
+
+# If you prefer to configure the network manually, uncomment this line and
+# the static network configuration below.
+#d-i netcfg/disable_autoconfig boolean true
+
+# If you want the preconfiguration file to work on systems both with and
+# without a dhcp server, uncomment these lines and the static network
+# configuration below.
+#d-i netcfg/dhcp_failed note
+#d-i netcfg/dhcp_options select Configure network manually
+
+# Static network configuration.
+#d-i netcfg/get_nameservers string 192.168.1.1
+#d-i netcfg/get_ipaddress string 192.168.1.42
+#d-i netcfg/get_netmask string 255.255.255.0
+#d-i netcfg/get_gateway string 192.168.1.1
+#d-i netcfg/confirm_static boolean true
+
+# Any hostname and domain names assigned from dhcp take precedence over
+# values set here. However, setting the values still prevents the questions
+# from being shown, even if values come from dhcp.
+d-i netcfg/get_hostname string stack
+d-i netcfg/get_domain string stackpass
+
+# Disable that annoying WEP key dialog.
+d-i netcfg/wireless_wep string
+# The wacky dhcp hostname that some ISPs use as a password of sorts.
+#d-i netcfg/dhcp_hostname string radish
+
+# If non-free firmware is needed for the network or other hardware, you can
+# configure the installer to always try to load it, without prompting. Or
+# change to false to disable asking.
+#d-i hw-detect/load_firmware boolean true
+
+### Network console
+# Use the following settings if you wish to make use of the network-console
+# component for remote installation over SSH. This only makes sense if you
+# intend to perform the remainder of the installation manually.
+#d-i anna/choose_modules string network-console
+#d-i network-console/password password r00tme
+#d-i network-console/password-again password r00tme
+
+### Mirror settings
+# If you select ftp, the mirror/country string does not need to be set.
+#d-i mirror/protocol string ftp
+d-i mirror/country string manual
+d-i mirror/http/hostname string archive.ubuntu.com
+d-i mirror/http/directory string /ubuntu
+d-i mirror/http/proxy string
+
+# Alternatively: by default, the installer uses CC.archive.ubuntu.com where
+# CC is the ISO-3166-2 code for the selected country. You can preseed this
+# so that it does so without asking.
+#d-i mirror/http/mirror select CC.archive.ubuntu.com
+
+# Suite to install.
+#d-i mirror/suite string squeeze
+# Suite to use for loading installer components (optional).
+#d-i mirror/udeb/suite string squeeze
+# Components to use for loading installer components (optional).
+#d-i mirror/udeb/components multiselect main, restricted
+
+### Clock and time zone setup
+# Controls whether or not the hardware clock is set to UTC.
+d-i clock-setup/utc boolean true
+
+# You may set this to any valid setting for $TZ; see the contents of
+# /usr/share/zoneinfo/ for valid values.
+d-i time/zone string US/Pacific
+
+# Controls whether to use NTP to set the clock during the install
+d-i clock-setup/ntp boolean true
+# NTP server to use. The default is almost always fine here.
+d-i clock-setup/ntp-server string 0.us.pool.ntp.org
+
+### Partitioning
+## Partitioning example
+# If the system has free space you can choose to only partition that space.
+# This is only honoured if partman-auto/method (below) is not set.
+# Alternatives: custom, some_device, some_device_crypto, some_device_lvm.
+#d-i partman-auto/init_automatically_partition select biggest_free
+
+# Alternatively, you may specify a disk to partition. If the system has only
+# one disk the installer will default to using that, but otherwise the device
+# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
+# /dev/sda, and not e.g. /dev/discs/disc0/disc).
+# For example, to use the first SCSI/SATA hard disk:
+#d-i partman-auto/disk string /dev/sda
+# In addition, you'll need to specify the method to use.
+# The presently available methods are:
+# - regular: use the usual partition types for your architecture
+# - lvm:     use LVM to partition the disk
+# - crypto:  use LVM within an encrypted partition
+d-i partman-auto/method string regular
+
+# If one of the disks that are going to be automatically partitioned
+# contains an old LVM configuration, the user will normally receive a
+# warning. This can be preseeded away...
+d-i partman-lvm/device_remove_lvm boolean true
+# The same applies to pre-existing software RAID array:
+d-i partman-md/device_remove_md boolean true
+# And the same goes for the confirmation to write the lvm partitions.
+d-i partman-lvm/confirm boolean true
+
+# For LVM partitioning, you can select how much of the volume group to use
+# for logical volumes.
+#d-i partman-auto-lvm/guided_size string max
+#d-i partman-auto-lvm/guided_size string 10GB
+#d-i partman-auto-lvm/guided_size string 50%
+
+# You can choose one of the three predefined partitioning recipes:
+# - atomic: all files in one partition
+# - home:   separate /home partition
+# - multi:  separate /home, /usr, /var, and /tmp partitions
+d-i partman-auto/choose_recipe select atomic
+
+# Or provide a recipe of your own...
+# If you have a way to get a recipe file into the d-i environment, you can
+# just point at it.
+#d-i partman-auto/expert_recipe_file string /hd-media/recipe
+
+# If not, you can put an entire recipe into the preconfiguration file in one
+# (logical) line. This example creates a small /boot partition, suitable
+# swap, and uses the rest of the space for the root partition:
+#d-i partman-auto/expert_recipe string                         \
+#      boot-root ::                                            \
+#              40 50 100 ext3                                  \
+#                      $primary{ } $bootable{ }                \
+#                      method{ format } format{ }              \
+#                      use_filesystem{ } filesystem{ ext3 }    \
+#                      mountpoint{ /boot }                     \
+#              .                                               \
+#              500 10000 1000000000 ext3                       \
+#                      method{ format } format{ }              \
+#                      use_filesystem{ } filesystem{ ext3 }    \
+#                      mountpoint{ / }                         \
+#              .                                               \
+#              64 512 300% linux-swap                          \
+#                      method{ swap } format{ }                \
+#              .
+
+# If you just want to change the default filesystem from ext3 to something
+# else, you can do that without providing a full recipe.
+d-i partman/default_filesystem string ext3
+
+# The full recipe format is documented in the file partman-auto-recipe.txt
+# included in the 'debian-installer' package or available from D-I source
+# repository. This also documents how to specify settings such as file
+# system labels, volume group names and which physical devices to include
+# in a volume group.
+
+# This makes partman automatically partition without confirmation, provided
+# that you told it what to do using one of the methods above.
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
+
+## Partitioning using RAID
+# The method should be set to "raid".
+#d-i partman-auto/method string raid
+# Specify the disks to be partitioned. They will all get the same layout,
+# so this will only work if the disks are the same size.
+#d-i partman-auto/disk string /dev/sda /dev/sdb
+
+# Next you need to specify the physical partitions that will be used. 
+#d-i partman-auto/expert_recipe string \
+#      multiraid ::                                         \
+#              1000 5000 4000 raid                          \
+#                      $primary{ } method{ raid }           \
+#              .                                            \
+#              64 512 300% raid                             \
+#                      method{ raid }                       \
+#              .                                            \
+#              500 10000 1000000000 raid                    \
+#                      method{ raid }                       \
+#              .
+
+# Last you need to specify how the previously defined partitions will be
+# used in the RAID setup. Remember to use the correct partition numbers
+# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported;
+# devices are separated using "#".
+# Parameters are:
+# <raidtype> <devcount> <sparecount> <fstype> <mountpoint> \
+#          <devices> <sparedevices>
+
+#d-i partman-auto-raid/recipe string \
+#    1 2 0 ext3 /                    \
+#          /dev/sda1#/dev/sdb1       \
+#    .                               \
+#    1 2 0 swap -                    \
+#          /dev/sda5#/dev/sdb5       \
+#    .                               \
+#    0 2 0 ext3 /home                \
+#          /dev/sda6#/dev/sdb6       \
+#    .
+
+# For additional information see the file partman-auto-raid-recipe.txt
+# included in the 'debian-installer' package or available from D-I source
+# repository.
+
+# This makes partman automatically partition without confirmation.
+d-i partman-md/confirm boolean true
+d-i partman-partitioning/confirm_write_new_label boolean true
+d-i partman/choose_partition select finish
+d-i partman/confirm boolean true
+d-i partman/confirm_nooverwrite boolean true
+
+## Controlling how partitions are mounted
+# The default is to mount by UUID, but you can also choose "traditional" to
+# use traditional device names, or "label" to try filesystem labels before
+# falling back to UUIDs.
+#d-i partman/mount_style select uuid
+
+### Base system installation
+# Configure APT to not install recommended packages by default. Use of this
+# option can result in an incomplete system and should only be used by very
+# experienced users.
+#d-i base-installer/install-recommends boolean false
+
+# The kernel image (meta) package to be installed; "none" can be used if no
+# kernel is to be installed.
+#d-i base-installer/kernel/image string linux-generic
+
+### Account setup
+# Skip creation of a root account (normal user account will be able to
+# use sudo). The default is false; preseed this to true if you want to set
+# a root password.
+d-i passwd/root-login boolean true
+# Alternatively, to skip creation of a normal user account.
+d-i passwd/make-user boolean false
+
+# Root password, either in clear text
+d-i passwd/root-password password stackpass
+d-i passwd/root-password-again password stackpass
+# or encrypted using an MD5 hash.
+#d-i passwd/root-password-crypted password [MD5 hash]
+
+# To create a normal user account.
+#d-i passwd/user-fullname string Ubuntu User
+#d-i passwd/username string ubuntu
+# Normal user's password, either in clear text
+#d-i passwd/user-password password insecure
+#d-i passwd/user-password-again password insecure
+# or encrypted using an MD5 hash.
+#d-i passwd/user-password-crypted password [MD5 hash]
+# Create the first user with the specified UID instead of the default.
+#d-i passwd/user-uid string 1010
+# The installer will warn about weak passwords. If you are sure you know
+# what you're doing and want to override it, uncomment this.
+d-i user-setup/allow-password-weak boolean true
+
+# The user account will be added to some standard initial groups. To
+# override that, use this.
+#d-i passwd/user-default-groups string audio cdrom video
+
+# Set to true if you want to encrypt the first user's home directory.
+d-i user-setup/encrypt-home boolean false
+
+### Apt setup
+# You can choose to install restricted and universe software, or to install
+# software from the backports repository.
+#d-i apt-setup/restricted boolean true
+#d-i apt-setup/universe boolean true
+#d-i apt-setup/backports boolean true
+# Uncomment this if you don't want to use a network mirror.
+#d-i apt-setup/use_mirror boolean false
+# Select which update services to use; define the mirrors to be used.
+# Values shown below are the normal defaults.
+#d-i apt-setup/services-select multiselect security
+#d-i apt-setup/security_host string security.ubuntu.com
+#d-i apt-setup/security_path string /ubuntu
+
+# Additional repositories, local[0-9] available
+#d-i apt-setup/local0/repository string \
+#       http://local.server/ubuntu squeeze main
+#d-i apt-setup/local0/comment string local server
+# Enable deb-src lines
+#d-i apt-setup/local0/source boolean true
+# URL to the public key of the local repository; you must provide a key or
+# apt will complain about the unauthenticated repository and so the
+# sources.list line will be left commented out
+#d-i apt-setup/local0/key string http://local.server/key
+
+# By default the installer requires that repositories be authenticated
+# using a known gpg key. This setting can be used to disable that
+# authentication. Warning: Insecure, not recommended.
+#d-i debian-installer/allow_unauthenticated boolean true
+
+### Package selection
+#tasksel tasksel/first multiselect ubuntu-desktop
+#tasksel tasksel/first multiselect lamp-server, print-server
+#tasksel tasksel/first multiselect kubuntu-desktop
+tasksel tasksel/first multiselect openssh-server
+
+# Individual additional packages to install
+#d-i pkgsel/include string openssh-server build-essential
+# Whether to upgrade packages after debootstrap.
+# Allowed values: none, safe-upgrade, full-upgrade
+#d-i pkgsel/upgrade select none
+
+# Language pack selection
+#d-i pkgsel/language-packs multiselect de, en, zh
+
+# Policy for applying updates. May be "none" (no automatic updates),
+# "unattended-upgrades" (install security updates automatically), or
+# "landscape" (manage system with Landscape).
+d-i pkgsel/update-policy select unattended-upgrades
+
+# Some versions of the installer can report back on what software you have
+# installed, and what software you use. The default is not to report back,
+# but sending reports helps the project determine what software is most
+# popular and include it on CDs.
+#popularity-contest popularity-contest/participate boolean false
+
+# By default, the system's locate database will be updated after the
+# installer has finished installing most packages. This may take a while, so
+# if you don't want it, you can set this to "false" to turn it off.
+d-i pkgsel/updatedb boolean false
+
+### Boot loader installation
+# Grub is the default boot loader (for x86). If you want lilo installed
+# instead, uncomment this:
+#d-i grub-installer/skip boolean true
+# To also skip installing lilo, and install no bootloader, uncomment this
+# too:
+#d-i lilo-installer/skip boolean true
+
+# With a few exceptions for unusual partitioning setups, GRUB 2 is now the
+# default. If you need GRUB Legacy for some particular reason, then
+# uncomment this:
+#d-i grub-installer/grub2_instead_of_grub_legacy boolean false
+
+# This is fairly safe to set, it makes grub install automatically to the MBR
+# if no other operating system is detected on the machine.
+d-i grub-installer/only_debian boolean true
+
+# This one makes grub-installer install to the MBR if it also finds some other
+# OS, which is less safe as it might not be able to boot that other OS.
+d-i grub-installer/with_other_os boolean true
+
+# Alternatively, if you want to install to a location other than the mbr,
+# uncomment and edit these lines:
+#d-i grub-installer/only_debian boolean false
+#d-i grub-installer/with_other_os boolean false
+#d-i grub-installer/bootdev  string (hd0,0)
+# To install grub to multiple disks:
+#d-i grub-installer/bootdev  string (hd0,0) (hd1,0) (hd2,0)
+
+# Optional password for grub, either in clear text
+#d-i grub-installer/password password r00tme
+#d-i grub-installer/password-again password r00tme
+# or encrypted using an MD5 hash, see grub-md5-crypt(8).
+#d-i grub-installer/password-crypted password [MD5 hash]
+
+# Use the following option to add additional boot parameters for the
+# installed system (if supported by the bootloader installer).
+# Note: options passed to the installer will be added automatically.
+#d-i debian-installer/add-kernel-opts string nousb
+
+### Finishing up the installation
+# During installations from serial console, the regular virtual consoles
+# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next
+# line to prevent this.
+d-i finish-install/keep-consoles boolean true
+
+# Avoid that last message about the install being complete.
+d-i finish-install/reboot_in_progress note
+
+# This will prevent the installer from ejecting the CD during the reboot,
+# which is useful in some situations.
+#d-i cdrom-detect/eject boolean false
+
+# This is how to make the installer shutdown when finished, but not
+# reboot into the installed system.
+#d-i debian-installer/exit/halt boolean true
+# This will power off the machine instead of just halting it.
+#d-i debian-installer/exit/poweroff boolean true
+
+### X configuration
+# X can detect the right driver for some cards, but if you're preseeding,
+# you override whatever it chooses. Still, vesa will work most places.
+#xserver-xorg xserver-xorg/config/device/driver select vesa
+
+# A caveat with mouse autodetection is that if it fails, X will retry it
+# over and over. So if it's preseeded to be done, there is a possibility of
+# an infinite loop if the mouse is not autodetected.
+#xserver-xorg xserver-xorg/autodetect_mouse boolean true
+
+# Monitor autodetection is recommended.
+xserver-xorg xserver-xorg/autodetect_monitor boolean true
+# Uncomment if you have an LCD display.
+#xserver-xorg xserver-xorg/config/monitor/lcd boolean true
+# X has three configuration paths for the monitor. Here's how to preseed
+# the "medium" path, which is always available. The "simple" path may not
+# be available, and the "advanced" path asks too many questions.
+xserver-xorg xserver-xorg/config/monitor/selection-method \
+       select medium
+xserver-xorg xserver-xorg/config/monitor/mode-list \
+       select 1024x768 @ 60 Hz
+
+### Preseeding other packages
+# Depending on what software you choose to install, or if things go wrong
+# during the installation process, it's possible that other questions may
+# be asked. You can preseed those too, of course. To get a list of every
+# possible question that could be asked during an install, do an
+# installation, and then run these commands:
+#   debconf-get-selections --installer > file
+#   debconf-get-selections >> file
+
+
+#### Advanced options
+### Running custom commands during the installation
+# d-i preseeding is inherently not secure. Nothing in the installer checks
+# for attempts at buffer overflows or other exploits of the values of a
+# preconfiguration file like this one. Only use preconfiguration files from
+# trusted locations! To drive that home, and because it's generally useful,
+# here's a way to run any shell command you'd like inside the installer,
+# automatically.
+
+# This first command is run as early as possible, just after
+# preseeding is read.
+#d-i preseed/early_command string anna-install some-udeb
+# This command is run immediately before the partitioner starts. It may be
+# useful to apply dynamic partitioner preseeding that depends on the state
+# of the disks (which may not be visible when preseed/early_command runs).
+#d-i partman/early_command \
+#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
+# This command is run just before the install finishes, but when there is
+# still a usable /target directory. You can chroot to /target and use it
+# directly, or use the apt-install and in-target commands to easily install
+# packages and run commands in the target system.
+#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
diff --git a/tools/xen/build_domU.sh b/tools/xen/install_os_domU.sh
similarity index 68%
rename from tools/xen/build_domU.sh
rename to tools/xen/install_os_domU.sh
index 5fa7aa8..3c25d4a 100755
--- a/tools/xen/build_domU.sh
+++ b/tools/xen/install_os_domU.sh
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Exit on errors
+set -o errexit
+
 # Abort if localrc is not set
 if [ ! -e ../../localrc ]; then
     echo "You must have a localrc with ALL necessary passwords defined before proceeding."
@@ -19,25 +22,29 @@
 # Echo commands
 set -o xtrace
 
-# Check for xva file
-if [ ! -e $XVA ]; then
-    echo "Missing xva file.  Please run build_xva.sh (ideally on a non dom0 host since the build can require lots of space)."
-    echo "Place the resulting xva file in $XVA"
-    exit 1
-fi
+xe_min()
+{
+  local cmd="$1"
+  shift
+  xe "$cmd" --minimal "$@"
+}
 
-# Make sure we have git
-if ! which git; then
-    GITDIR=/tmp/git-1.7.7
-    cd /tmp
-    rm -rf $GITDIR*
-    wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
-    tar xfv git-1.7.7.tar.gz
-    cd $GITDIR
-    ./configure --with-curl --with-expat
-    make install
-    cd $TOP_DIR
+cd $TOP_DIR
+if [ -f ./master ]
+then
+    rm -rf ./master
+    rm -rf ./nova
 fi
+wget https://github.com/openstack/nova/zipball/master --no-check-certificate
+unzip -o master -d ./nova
+cp -pr ./nova/*/plugins/xenserver/xenapi/etc/xapi.d /etc/
+chmod a+x /etc/xapi.d/plugins/*
+
+mkdir -p /boot/guest
+
+GUEST_NAME=${GUEST_NAME:-"DevStackOSDomU"}
+SNAME="ubuntusnapshot"
+TNAME="ubuntuready"
 
 # Helper to create networks
 # Uses echo trickery to return network uuid
@@ -48,23 +55,23 @@
     netname=$4
     if [ -z $br ]
     then
-        pif=$(xe pif-list --minimal device=$dev VLAN=$vlan)
+        pif=$(xe_min pif-list device=$dev VLAN=$vlan)
         if [ -z $pif ]
         then
             net=$(xe network-create name-label=$netname)
         else
-            net=$(xe network-list --minimal PIF-uuids=$pif)
+            net=$(xe_min network-list  PIF-uuids=$pif)
         fi
         echo $net
         return 0
     fi
-    if [ ! $(xe network-list --minimal params=bridge | grep -w --only-matching $br) ]
+    if [ ! $(xe_min network-list  params=bridge | grep -w --only-matching $br) ]
     then
         echo "Specified bridge $br does not exist"
         echo "If you wish to use defaults, please keep the bridge name empty"
         exit 1
     else
-        net=$(xe network-list --minimal bridge=$br)
+        net=$(xe_min network-list  bridge=$br)
         echo $net
     fi
 }
@@ -95,13 +102,13 @@
     then
         return
     fi
-    if [ -z $(xe vlan-list --minimal tag=$vlan) ]
+    if [ -z $(xe_min vlan-list  tag=$vlan) ]
     then
-        pif=$(xe pif-list --minimal network-uuid=$net)
+        pif=$(xe_min pif-list  network-uuid=$net)
         # We created a brand new network this time
         if [ -z $pif ]
         then
-            pif=$(xe pif-list --minimal device=$dev VLAN=-1)
+            pif=$(xe_min pif-list  device=$dev VLAN=-1)
             xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
         else
             echo "VLAN does not exist but PIF attached to this network"
@@ -133,30 +140,17 @@
 # Enable ip forwarding at runtime as well
 echo 1 > /proc/sys/net/ipv4/ip_forward
 
-# Set local storage il8n
-SR_UUID=`xe sr-list --minimal name-label="Local storage"`
-xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
-
-# Checkout nova
-git_clone $NOVA_REPO $TOP_DIR/nova $NOVA_BRANCH
-
-# Install plugins
-cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
-chmod a+x /etc/xapi.d/plugins/*
-yum --enablerepo=base install -y parted
-mkdir -p /boot/guest
-
 # Shutdown previous runs
 DO_SHUTDOWN=${DO_SHUTDOWN:-1}
 if [ "$DO_SHUTDOWN" = "1" ]; then
     # Shutdown all domU's that created previously
-    xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh
+    xe_min vm-list  name-label="$GUEST_NAME" | xargs ./scripts/uninstall-os-vpx.sh
 
     # Destroy any instances that were launched
     for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
         echo "Shutting down nova instance $uuid"
         xe vm-unpause uuid=$uuid || true
-        xe vm-shutdown uuid=$uuid
+        xe vm-shutdown uuid=$uuid || true
         xe vm-destroy uuid=$uuid
     done
 
@@ -168,18 +162,55 @@
 
 # Start guest
 if [ -z $VM_BR ]; then
-    VM_BR=$(xe network-list --minimal uuid=$VM_NET params=bridge)
+    VM_BR=$(xe_min network-list  uuid=$VM_NET params=bridge)
 fi
 if [ -z $MGT_BR ]; then
-    MGT_BR=$(xe network-list --minimal uuid=$MGT_NET params=bridge)
+    MGT_BR=$(xe_min network-list  uuid=$MGT_NET params=bridge)
 fi
 if [ -z $PUB_BR ]; then
-    PUB_BR=$(xe network-list --minimal uuid=$PUB_NET params=bridge)
+    PUB_BR=$(xe_min network-list  uuid=$PUB_NET params=bridge)
 fi
-$TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR -l $GUEST_NAME -w -k "flat_network_bridge=${VM_BR}"
+
+templateuuid=$(xe template-list name-label="$TNAME")
+if [ -n "$templateuuid" ]
+then
+        vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$GUEST_NAME")
+else
+    template=$(xe_min template-list name-label="Ubuntu 11.10 (64-bit)")
+    if [ -z "$template" ]
+    then
+        cp $TOP_DIR/devstackubuntupreseed.cfg /opt/xensource/www/
+        $TOP_DIR/scripts/xenoneirictemplate.sh "${HOST_IP}/devstackubuntupreseed.cfg"
+    fi
+    $TOP_DIR/scripts/install-os-vpx.sh -t "Ubuntu 11.10 (64-bit)" -v $VM_BR -m $MGT_BR -p $PUB_BR -l $GUEST_NAME -r $OSDOMU_MEM_MB -k "flat_network_bridge=${VM_BR}"
+
+    # Wait for install to finish
+    while true
+    do
+        state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
+        if [ -n "$state" ]
+        then
+            break
+        else
+            echo "Waiting for "$GUEST_NAME" to finish installation..."
+            sleep 30
+        fi
+    done
+
+    vm_uuid=$(xe_min vm-list name-label="$GUEST_NAME")
+    xe vm-param-set actions-after-reboot=Restart uuid="$vm_uuid"
+
+    # Make template from VM
+    snuuid=$(xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME")
+    template_uuid=$(xe snapshot-clone uuid=$snuuid new-name-label="$TNAME")
+fi
+
+$TOP_DIR/build_xva.sh "$GUEST_NAME"
+
+xe vm-start vm="$GUEST_NAME"
 
 if [ $PUB_IP == "dhcp" ]; then
-    PUB_IP=$(xe vm-list --minimal name-label=$GUEST_NAME params=networks |  sed -ne 's,^.*3/ip: \([0-9.]*\).*$,\1,p')
+    PUB_IP=$(xe_min vm-list  name-label=$GUEST_NAME params=networks |  sed -ne 's,^.*3/ip: \([0-9.]*\).*$,\1,p')
 fi
 
 # If we have copied our ssh credentials, use ssh to monitor while the installation runs
diff --git a/tools/xen/prepare_guest.sh b/tools/xen/prepare_guest.sh
old mode 100644
new mode 100755
index 77ce54a..5d39ac6
--- a/tools/xen/prepare_guest.sh
+++ b/tools/xen/prepare_guest.sh
@@ -6,13 +6,6 @@
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
 STAGING_DIR=${STAGING_DIR:-stage}
 DO_TGZ=${DO_TGZ:-1}
-KERNEL_VERSION=3.0.0-12-virtual
-
-# Debootstrap base system
-if [ ! -d $STAGING_DIR ]; then
-    apt-get install debootstrap
-    debootstrap --arch amd64 oneiric $STAGING_DIR http://us.archive.ubuntu.com/ubuntu/
-fi
 
 # Sources.list
 cat <<EOF >$STAGING_DIR/etc/apt/sources.list
@@ -28,7 +21,6 @@
 
 # Install basics
 chroot $STAGING_DIR apt-get update
-chroot $STAGING_DIR apt-get install -y linux-image-$KERNEL_VERSION
 chroot $STAGING_DIR apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
 chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo
 chroot $STAGING_DIR pip install xenapi
diff --git a/tools/xen/scripts/install-os-vpx.sh b/tools/xen/scripts/install-os-vpx.sh
index d45c370..fe5e810 100755
--- a/tools/xen/scripts/install-os-vpx.sh
+++ b/tools/xen/scripts/install-os-vpx.sh
@@ -38,7 +38,7 @@
 cat << EOF
 
   Usage: $0 [-f FILE_PATH] [-d DISK_SIZE] [-v BRIDGE_NAME] [-m BRIDGE_NAME] [-p BRIDGE_NAME]
-            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b] [-l NAME_LABEL]
+            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b] [-l NAME_LABEL] [-t TEMPLATE_NW_INSTALL]
 
   Installs XenServer OpenStack VPX.
 
@@ -61,6 +61,7 @@
      -r MiB       Specifies RAM used by the VPX, in MiB.
                   By default it will take the value from the XVA.
      -l name      Specifies the name label for the VM.
+     -t template  Network install an openstack domU from this template
 
   EXAMPLES:
 
@@ -88,7 +89,7 @@
 
 get_params()
 {
-  while getopts "hicwbf:d:v:m:p:k:r:l:" OPTION;
+  while getopts "hicwbf:d:v:m:p:k:r:l:t:" OPTION;
   do
     case $OPTION in
       h) usage
@@ -127,9 +128,12 @@
       v)
          BRIDGE_V=$OPTARG
          ;;
-     l)
+      l)
          NAME_LABEL=$OPTARG
          ;;
+      t)
+         TEMPLATE_NAME=$OPTARG
+         ;;
       ?)
          usage
          exit
@@ -328,17 +332,11 @@
 {
   local v="$1"
   local args=$KERNEL_PARAMS
-  local cmdline=$(cat /proc/cmdline)
-  for word in $cmdline
-  do
-    if echo "$word" | grep -q "geppetto"
-    then
-      args="$word $args"
-    fi
-  done
   if [ "$args" != "" ]
   then
     echo "Passing Geppetto args to VPX: $args."
+    pvargs=$(xe vm-param-get param-name=PV-args uuid="$v")
+    args="$pvargs $args"
     xe vm-param-set PV-args="$args" uuid="$v"
   fi
 }
@@ -422,6 +420,20 @@
 
   destroy_vifs "$vm_uuid"
   set_all "$vm_uuid"
+elif [ "$TEMPLATE_NAME" ]
+then
+  echo $TEMPLATE_NAME
+  vm_uuid=$(xe_min vm-install template="$TEMPLATE_NAME" new-name-label="$NAME_LABEL")
+  destroy_vifs "$vm_uuid"
+  set_auto_start "$vm_uuid"
+  create_gi_vif "$vm_uuid"
+  create_vm_vif "$vm_uuid"
+  create_management_vif "$vm_uuid"
+  create_public_vif "$vm_uuid"
+  set_kernel_params "$vm_uuid"
+  xe vm-param-set other-config:os-vpx=true uuid="$vm_uuid"
+  xe vm-param-set actions-after-reboot=Destroy uuid="$vm_uuid"
+  set_memory "$vm_uuid"
 else
   if [ ! -f "$VPX_FILE" ]
   then
diff --git a/tools/xen/scripts/manage-vdi b/tools/xen/scripts/manage-vdi
new file mode 100755
index 0000000..a0a27e8
--- /dev/null
+++ b/tools/xen/scripts/manage-vdi
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+set -eux
+
+action="$1"
+vm="$2"
+device="${3-0}"
+part="${4-}"
+
+xe_min()
+{
+  local cmd="$1"
+  shift
+  xe "$cmd" --minimal "$@"
+}
+
+vm_uuid=$(xe_min vm-list name-label="$vm")
+vdi_uuid=$(xe_min vbd-list params=vdi-uuid vm-uuid="$vm_uuid" \
+                           userdevice="$device")
+
+dom0_uuid=$(xe_min vm-list is-control-domain=true)
+
+open_vdi()
+{
+  vbd_uuid=$(xe vbd-create vm-uuid="$dom0_uuid" vdi-uuid="$vdi_uuid" \
+                         device=autodetect)
+  mp=$(mktemp -d)
+  xe vbd-plug uuid="$vbd_uuid"
+
+  udevsettle
+  dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
+  mount "/dev/$dev$part" "$mp"
+  echo "Your vdi is mounted at $mp"
+}
+
+close_vdi()
+{
+  vbd_uuid=$(xe_min vbd-list vm-uuid="$dom0_uuid" vdi-uuid="$vdi_uuid")
+  dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
+  umount "/dev/$dev$part"
+
+  xe vbd-unplug uuid=$vbd_uuid
+  xe vbd-destroy uuid=$vbd_uuid
+}
+
+if [ "$action" == "open" ]
+then
+  open_vdi
+elif [ "$action" == "close" ]
+then
+  close_vdi
+fi
diff --git a/tools/xen/scripts/xenoneirictemplate.sh b/tools/xen/scripts/xenoneirictemplate.sh
new file mode 100755
index 0000000..1d9ec5e
--- /dev/null
+++ b/tools/xen/scripts/xenoneirictemplate.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+## makeubuntu.sh, this creates Ubuntu server 11.10 32 and 64 bit templates
+## on Xenserver 6.0.2 Net install only
+## Original Author: David Markey <david.markey@citrix.com>
+## Author: Renuka Apte <renuka.apte@citrix.com>
+## This is not an officially supported guest OS on XenServer 6.02
+
+BASE_DIR=$(cd $(dirname "$0") && pwd)
+source $BASE_DIR/../../../localrc
+
+LENNY=$(xe template-list name-label=Debian\ Lenny\ 5.0\ \(32-bit\) --minimal)
+
+if [[ -z $LENNY ]] ; then
+    echo "Cant find lenny 32bit template, is this on 6.0.2?"
+    exit 1
+fi
+
+distro="Ubuntu 11.10"
+arches=("32-bit" "64-bit")
+
+preseedurl=${1:-"http://images.ansolabs.com/devstackubuntupreseed.cfg"}
+
+for arch in ${arches[@]} ; do
+    echo "Attempting $distro ($arch)"
+    if [[ -n $(xe template-list name-label="$distro ($arch)" params=uuid --minimal) ]] ; then
+        echo "$distro ($arch)" already exists, Skipping
+    else
+        if [ -z $NETINSTALLIP ]
+        then
+            echo "NETINSTALLIP not set in localrc"
+            exit 1
+        fi
+        pvargs="-- quiet console=hvc0 partman/default_filesystem=ext3 locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=us netcfg/choose_interface=eth3 netcfg/get_hostname=os netcfg/get_domain=os auto url=${preseedurl}"
+        if [ "$NETINSTALLIP" != "dhcp" ]
+        then
+            netcfgargs="netcfg/disable_autoconfig=true netcfg/get_nameservers=${NAMESERVERS} netcfg/get_ipaddress=${NETINSTALLIP} netcfg/get_netmask=${NETMASK} netcfg/get_gateway=${GATEWAY} netcfg/confirm_static=true"
+            pvargs="${pvargs} ${netcfgargs}"
+        fi
+        NEWUUID=$(xe vm-clone uuid=$LENNY new-name-label="$distro ($arch)")
+        xe template-param-set uuid=$NEWUUID other-config:install-methods=http,ftp \
+         other-config:install-repository=http://archive.ubuntu.net/ubuntu \
+         PV-args="$pvargs" \
+         other-config:debian-release=oneiric \
+         other-config:default_template=true
+
+        if [[ "$arch" == "32-bit" ]] ; then
+            xe template-param-set uuid=$NEWUUID other-config:install-arch="i386"
+        else
+            xe template-param-set uuid=$NEWUUID other-config:install-arch="amd64"
+        fi
+        echo "Success"
+    fi
+done
+
+echo "Done"
diff --git a/tools/xen/xenrc b/tools/xen/xenrc
index 58fda31..f434b11 100644
--- a/tools/xen/xenrc
+++ b/tools/xen/xenrc
@@ -1,10 +1,10 @@
 #!/bin/bash
 
 # Name of this guest
-GUEST_NAME=${GUEST_NAME:-ALLINONE}
+GUEST_NAME=${GUEST_NAME:-DevStackOSDomU}
 
 # Size of image
-VDI_MB=${VDI_MB:-2500}
+VDI_MB=${VDI_MB:-5000}
 
 # VM Password
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
@@ -35,11 +35,7 @@
 MGT_VLAN=${MGT_VLAN:-101}
 MGT_DEV=${MGT_DEV:-eth0}
 
-# XVA Directory
-XVA_DIR=${XVA_DIR:-`pwd`/xvas}
-
-# Path to xva file
-XVA=${XVA:-$XVA_DIR/$GUEST_NAME.xva }
+OSDOMU_MEM_MB=1024
 
 # Source params
 cd ../.. && source ./stackrc && cd $TOP_DIR