Improvements to DevStack's XenServer scripts
I have ensured:
- template gets re-used on second run
- template includes XenServer tools, and custom user accounts
- take snapshot before first boot, for easy re-run
- make host_ip_iface work with either eth2 or eth3
- make ssh into domU checks looser
- above is all ground work for improved jenkins tests
- added some more comments to make it scripts clearer
Change-Id: I5c45370bf8a1393d669480e196b13f592d29154f
diff --git a/tools/xen/scripts/uninstall-os-vpx.sh b/tools/xen/scripts/uninstall-os-vpx.sh
index a82f3a0..0feaec7 100755
--- a/tools/xen/scripts/uninstall-os-vpx.sh
+++ b/tools/xen/scripts/uninstall-os-vpx.sh
@@ -17,19 +17,19 @@
# under the License.
#
-remove_data=
-if [ "$1" = "--remove-data" ]
-then
- remove_data=1
-fi
+set -ex
-set -eu
+# By default, don't remove the templates
+REMOVE_TEMPLATES=${REMOVE_TEMPLATES:-"false"}
+if [ "$1" = "--remove-templates" ]; then
+ REMOVE_TEMPLATES=true
+fi
xe_min()
{
local cmd="$1"
shift
- /opt/xensource/bin/xe "$cmd" --minimal "$@"
+ xe "$cmd" --minimal "$@"
}
destroy_vdi()
@@ -39,11 +39,8 @@
local dev=$(xe_min vbd-list uuid=$vbd_uuid params=userdevice)
local vdi_uuid=$(xe_min vbd-list uuid=$vbd_uuid params=vdi-uuid)
- if [ "$type" = 'Disk' ] && [ "$dev" != 'xvda' ] && [ "$dev" != '0' ]
- then
- echo -n "Destroying data disk... "
+ if [ "$type" == 'Disk' ] && [ "$dev" != 'xvda' ] && [ "$dev" != '0' ]; then
xe vdi-destroy uuid=$vdi_uuid
- echo "done."
fi
}
@@ -52,50 +49,36 @@
local vm_uuid="$1"
local power_state=$(xe_min vm-list uuid=$vm_uuid params=power-state)
- if [ "$power_state" != "halted" ]
- then
- echo -n "Shutting down VM... "
+ if [ "$power_state" != "halted" ]; then
xe vm-shutdown vm=$vm_uuid force=true
- echo "done."
fi
- if [ "$remove_data" = "1" ]
- then
- for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
- do
- destroy_vdi "$v"
- done
- fi
+ for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g'); do
+ destroy_vdi "$v"
+ done
- echo -n "Deleting VM... "
xe vm-uninstall vm=$vm_uuid force=true >/dev/null
- echo "done."
}
uninstall_template()
{
local vm_uuid="$1"
- if [ "$remove_data" = "1" ]
- then
- for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
- do
- destroy_vdi "$v"
- done
- fi
+ for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g'); do
+ destroy_vdi "$v"
+ done
- echo -n "Deleting template... "
xe template-uninstall template-uuid=$vm_uuid force=true >/dev/null
- echo "done."
}
-
-for u in $(xe_min vm-list other-config:os-vpx=true | sed -e 's/,/ /g')
-do
+# remove the VMs and their disks
+for u in $(xe_min vm-list other-config:os-vpx=true | sed -e 's/,/ /g'); do
uninstall "$u"
done
-for u in $(xe_min template-list other-config:os-vpx=true | sed -e 's/,/ /g')
-do
- uninstall_template "$u"
-done
+# remove the templates
+if [ "$REMOVE_TEMPLATES" == "true" ]; then
+ for u in $(xe_min template-list other-config:os-vpx=true | sed -e 's/,/ /g'); do
+ uninstall_template "$u"
+ done
+fi