bifrost: scripts: Look for virtualbmc on bifrost virtualenv 79/42279/9
authorMarkos Chandras <mchandras@suse.de>
Mon, 18 Sep 2017 14:33:54 +0000 (15:33 +0100)
committerMarkos Chandras <mchandras@suse.de>
Thu, 21 Sep 2017 20:51:43 +0000 (21:51 +0100)
Since I94874d600a29247b7826324cc111901995df90dc, bifrost installs pip
packages in virtualenv so we need to look there for virtualbmc if it's
not currently installed on the host.

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

index 87f792a..f6eca4e 100755 (executable)
@@ -19,12 +19,17 @@ rm -rf /opt/stack
 # HOME is normally set by sudo -H
 rm -rf ${HOME}/.config/openstack
 
-# Delete all libvirt VMs and hosts from vbmc (look for a port number)
-for vm in $(vbmc list | awk '/[0-9]/{{ print $2 }}'); do
-    virsh destroy $vm || true
-    virsh undefine $vm || true
-    vbmc delete $vm
-done
+# bifrost installs everything on venv so we need to look there if virtualbmc is not installed on the host.
+if which vbmc &>/dev/null || { [[ -e /opt/stack/bifrost/bin/activate ]] && source /opt/stack/bifrost/bin/activate; }; then
+       # Delete all libvirt VMs and hosts from vbmc (look for a port number)
+       for vm in $(vbmc list | awk '/[0-9]/{{ print $2 }}'); do
+               virsh destroy $vm || true
+               virsh undefine $vm || true
+               vbmc delete $vm
+       done
+       which vbmc &>/dev/null || { [[ -e /opt/stack/bifrost/bin/activate ]] && deactivate; }
+fi
+
 # Destroy all XCI VMs if the previous operation failed
 [[ -n ${XCI_FLAVOR} ]] && \
     for vm in ${TEST_VM_NODE_NAMES}; do