Make it easier to use Precise or Oneric with XenServer DevStack
This is a partial fix for bug 1009937
Change-Id: I1fc7059cd812bce1539a5050f60717db4cbd81ef
diff --git a/tools/xen/scripts/install_ubuntu_template.sh b/tools/xen/scripts/install_ubuntu_template.sh
new file mode 100755
index 0000000..f67547b
--- /dev/null
+++ b/tools/xen/scripts/install_ubuntu_template.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+#
+# This creates an Ubuntu Server 32bit or 64bit template
+# on Xenserver 5.6.x, 6.0.x and 6.1.x
+# The template does a net install only
+#
+# Based on a script by: David Markey <david.markey@citrix.com>
+#
+
+# Exit on errors
+set -o errexit
+# Echo commands
+set -o xtrace
+
+# This directory
+BASE_DIR=$(cd $(dirname "$0") && pwd)
+
+# For default setings see xenrc
+source $BASE_DIR/../xenrc
+
+# Get the params
+preseed_url=$1
+
+# Delete template or skip template creation as required
+previous_template=$(xe template-list name-label="$UBUNTU_INST_TEMPLATE_NAME" \
+ params=uuid --minimal)
+if [ -n "$previous_template" ]; then
+ if $CLEAN_TEMPLATES; then
+ xe template-param-clear param-name=other-config uuid=$previous_template
+ xe template-uninstall template-uuid=$previous_template force=true
+ else
+ echo "Template $UBUNTU_INST_TEMPLATE_NAME already present"
+ exit 0
+ fi
+fi
+
+# Get built-in template
+builtin_name="Debian Squeeze 6.0 (32-bit)"
+builtin_uuid=$(xe template-list name-label="$builtin_name" --minimal)
+if [[ -z $builtin_uuid ]]; then
+ echo "Cant find the Debian Squeeze 32bit template on your XenServer."
+ exit 1
+fi
+
+# Clone built-in template to create new template
+new_uuid=$(xe vm-clone uuid=$builtin_uuid \
+ new-name-label="$UBUNTU_INST_TEMPLATE_NAME")
+
+# Some of these settings can be found in example preseed files
+# however these need to be answered before the netinstall
+# is ready to fetch the preseed file, and as such must be here
+# to get a fully automated install
+pvargs="-- quiet console=hvc0 partman/default_filesystem=ext3 \
+console-setup/ask_detect=false locale=${UBUNTU_INST_LOCALE} \
+keyboard-configuration/layoutcode=${UBUNTU_INST_KEYBOARD} \
+netcfg/choose_interface=${HOST_IP_IFACE} \
+netcfg/get_hostname=os netcfg/get_domain=os auto \
+url=${preseed_url}"
+
+if [ "$NETINSTALLIP" != "dhcp" ]; then
+ netcfgargs="netcfg/disable_autoconfig=true \
+netcfg/get_nameservers=${UBUNTU_INST_NAMESERVERS} \
+netcfg/get_ipaddress=${UBUNTU_INST_IP} \
+netcfg/get_netmask=${UBUNTU_INST_NETMASK} \
+netcfg/get_gateway=${UBUNTU_INST_GATEWAY} \
+netcfg/confirm_static=true"
+ pvargs="${pvargs} ${netcfgargs}"
+fi
+
+xe template-param-set uuid=$new_uuid \
+ other-config:install-methods=http \
+ other-config:install-repository="$UBUNTU_INST_REPOSITORY" \
+ PV-args="$pvargs" \
+ other-config:debian-release="$UBUNTU_INST_RELEASE" \
+ other-config:default_template=true \
+ other-config:install-arch="$UBUNTU_INST_ARCH"
+
+echo "Ubuntu template installed uuid:$new_uuid"
diff --git a/tools/xen/scripts/xenoneirictemplate.sh b/tools/xen/scripts/xenoneirictemplate.sh
deleted file mode 100755
index 7f10c33..0000000
--- a/tools/xen/scripts/xenoneirictemplate.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/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.0.2
-
-BASE_DIR=$(cd $(dirname "$0") && pwd)
-source $BASE_DIR/../../../localrc
-
-LENNY=$(xe template-list name-label=Debian\ Squeeze\ 6.0\ \(32-bit\) --minimal)
-
-if [[ -z $LENNY ]] ; then
- echo "Cant find Squeeze 32bit template."
- exit 1
-fi
-
-distro="Ubuntu 11.10 for DevStack"
-arches=("32-bit" "64-bit")
-
-preseedurl=${1:-"http://images.ansolabs.com/devstackubuntupreseed.cfg"}
-
-NETINSTALL_LOCALE=${NETINSTALL_LOCALE:-en_US}
-NETINSTALL_KEYBOARD=${NETINSTALL_KEYBOARD:-us}
-NETINSTALL_IFACE=${NETINSTALL_IFACE:-eth3}
-
-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
- # Some of these settings can be found in example preseed files
- # however these need to be answered before the netinstall
- # is ready to fetch the preseed file, and as such must be here
- # to get a fully automated install
- pvargs="-- quiet console=hvc0 partman/default_filesystem=ext3 locale=${NETINSTALL_LOCALE} console-setup/ask_detect=false keyboard-configuration/layoutcode=${NETINSTALL_KEYBOARD} netcfg/choose_interface=${NETINSTALL_IFACE} 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"