Browse code

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>

Kevin Zhao authored on 2017/02/08 11:54:29
Showing 1 changed files
... ...
@@ -202,7 +202,10 @@ function cleanup_nova {
202 202
         instances=`sudo virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"`
203 203
         if [ ! "$instances" = "" ]; then
204 204
             echo $instances | xargs -n1 sudo virsh destroy || true
205
-            echo $instances | xargs -n1 sudo virsh undefine --managed-save || true
205
+            if ! xargs -n1 sudo virsh undefine --managed-save --nvram <<< $instances; then
206
+                # Can't delete with nvram flags, then just try without this flag
207
+                xargs -n1 sudo virsh undefine --managed-save <<< $instances
208
+            fi
206 209
         fi
207 210
 
208 211
         # Logout and delete iscsi sessions