Add "--nvram" to virsh undefine domain when clean_nova

For the instance which has boot by uefi, we should use
virsh undefine --nvram to undefine it. Check the libvirt
version for whether it supports nvram and use new undefine
parameters since this parameters is compatible with those
instance which don't use uefi.

Closes-bug: #1612613

Change-Id: Ibca1450e965df1481e6cd6b0d597b4323d667e60
Signed-off-by: Kevin Zhao <kevin.zhao@linaro.org>
This commit is contained in:
Kevin Zhao
2017-02-08 10:54:29 +08:00
parent bab8516a85
commit cfc3edc97c

View File

@@ -202,7 +202,10 @@ function cleanup_nova {
instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"` instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
if [ ! "$instances" = "" ]; then if [ ! "$instances" = "" ]; then
echo $instances | xargs -n1 sudo virsh destroy || true echo $instances | xargs -n1 sudo virsh destroy || true
echo $instances | xargs -n1 sudo virsh undefine --managed-save || true if ! xargs -n1 sudo virsh undefine --managed-save --nvram <<< $instances; then
# Can't delete with nvram flags, then just try without this flag
xargs -n1 sudo virsh undefine --managed-save <<< $instances
fi
fi fi
# Logout and delete iscsi sessions # Logout and delete iscsi sessions