prototypes: bifrost: destroy-env: Always destroy XCI VMs 53/39153/2
authorMarkos Chandras <mchandras@suse.de>
Wed, 26 Jul 2017 10:25:22 +0000 (11:25 +0100)
committerMarkos Chandras <mchandras@suse.de>
Thu, 17 Aug 2017 13:48:06 +0000 (13:48 +0000)
It's possible that a previous run failed before registering the VMs
to the vbmc. As such, consulting the vbmc to retrieve the VM names will
return nothing and no VM will be deleted. As such, it's best to get
the VMs from the currently XCI profile and make sure they are really
gone.

Change-Id: If11265655f42c8a1c7627c9139ac0cbfc002b1fe
Signed-off-by: Markos Chandras <mchandras@suse.de>
bifrost/scripts/destroy-env.sh

index c75e814..87f792a 100755 (executable)
@@ -25,6 +25,12 @@ for vm in $(vbmc list | awk '/[0-9]/{{ print $2 }}'); do
     virsh undefine $vm || true
     vbmc delete $vm
 done
+# Destroy all XCI VMs if the previous operation failed
+[[ -n ${XCI_FLAVOR} ]] && \
+    for vm in ${TEST_VM_NODE_NAMES}; do
+        virsh destroy $vm || true
+        virsh undefine $vm || true
+    done
 
 service ironic-conductor stop || true