xci: Destroy/undefine only the VMs we created
[releng.git] / prototypes / bifrost / scripts / destroy-env.sh
index b73092b..ce9d535 100755 (executable)
@@ -14,15 +14,18 @@ if [[ $(whoami) != "root" ]]; then
     exit 1
 fi
 
-# Delete all VMs on the slave since proposed patchsets
-# may leave undesired VM leftovers
-for vm in $(virsh list --all --name); do
+# 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
 
 service ironic-conductor stop || true
 
+echo "removing inventory files created by previous builds"
+rm -rf /tmp/baremetal.*
+
 echo "removing ironic database"
 if $(which mysql &> /dev/null); then
     mysql -u root ironic --execute "drop database ironic;"
@@ -47,6 +50,6 @@ rm -rf /var/lib/libvirt/images/*.qcow2
 echo "restarting services"
 service dnsmasq restart || true
 service libvirtd restart
-service ironic-api restart || true 
+service ironic-api restart || true
 service ironic-conductor start || true
 service ironic-inspector restart || true