prototypes: bifrost: Remove /opt/stack from previous deployments
[releng.git] / prototypes / bifrost / scripts / destroy-env.sh
index 9920046..d570f10 100755 (executable)
@@ -14,26 +14,29 @@ if [[ $(whoami) != "root" ]]; then
     exit 1
 fi
 
-virsh destroy jumphost.opnfvlocal || true
-virsh destroy controller00.opnfvlocal || true
-virsh destroy compute00.opnfvlocal || true
-virsh undefine jumphost.opnfvlocal || true
-virsh undefine controller00.opnfvlocal || true
-virsh undefine compute00.opnfvlocal || true
+# Start fresh
+rm -rf /opt/stack
+
+# 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 from database"
+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 "truncate table ports;"
-    mysql -u root ironic --execute "delete from node_tags;"
-    mysql -u root ironic --execute "delete from nodes;"
-    mysql -u root ironic --execute "delete from conductors;"
+    mysql -u root ironic --execute "drop database ironic;"
 fi
 echo "removing leases"
 [[ -e /var/lib/misc/dnsmasq/dnsmasq.leases ]] && > /var/lib/misc/dnsmasq/dnsmasq.leases
 echo "removing logs"
-rm -rf /var/log/libvirt/baremetal_logs/*.log
+rm -rf /var/log/libvirt/baremetal_logs/*
 
 # clean up dib images only if requested explicitly
 CLEAN_DIB_IMAGES=${CLEAN_DIB_IMAGES:-false}
@@ -50,6 +53,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