clean.sh 1.39 KB
Newer Older
1 2
#!/usr/bin/env bash

Dan Radez's avatar
Dan Radez committed
3
#Clean script to uninstall provisioning server for Apex
4 5
#author: Dan Radez (dradez@redhat.com)
#
Tim Rozet's avatar
Tim Rozet committed
6
vm_index=4
7
ovs_bridges="brbm brbm1 brbm2 brbm3"
Dan Radez's avatar
Dan Radez committed
8
# Clean off instack VM
9 10
virsh destroy instack 2> /dev/null || echo -n ''
virsh undefine instack --remove-all-storage 2> /dev/null || echo -n ''
11 12 13 14 15 16 17
if ! virsh vol-delete instack.qcow2 --pool default; then
  if [ ! -e /var/lib/libvirt/images/instack.qcow2 ]; then
    /usr/bin/touch /var/lib/libvirt/images/instack.qcow2
    virsh vol-delete instack.qcow2 --pool default
  fi
fi

18
rm -f /var/lib/libvirt/images/instack.qcow2 2> /dev/null
Dan Radez's avatar
Dan Radez committed
19 20

# Clean off baremetal VMs in case they exist
Dan Radez's avatar
Dan Radez committed
21
for i in $(seq 0 $vm_index); do
22 23 24 25
  virsh destroy baremetalbrbm_brbm1_brbm2_brbm3_$i 2> /dev/null || echo -n ''
  virsh undefine baremetalbrbm_brbm1_brbm2_brbm3_$i --remove-all-storage 2> /dev/null || echo -n ''
  virsh vol-delete baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 --pool default 2> /dev/null
  rm -f /var/lib/libvirt/images/baremetalbrbm_brbm1_brbm2_brbm3_${i}.qcow2 2> /dev/null
Tim Rozet's avatar
Tim Rozet committed
26
done
Dan Radez's avatar
Dan Radez committed
27

28 29 30 31 32 33
# Clean off created bridges
for bridge in ${ovs_bridges}; do
  virsh net-destroy ${bridge} 2> /dev/null
  virsh net-undefine ${bridge} 2> /dev/null
  ovs-vsctl del-br ${bridge} 2> /dev/null
done
Dan Radez's avatar
Dan Radez committed
34

35 36 37 38 39
# clean pub keys from root's auth keys
sed -i '/stack@instack.localdomain/d' /root/.ssh/authorized_keys
sed -i '/virtual-power-key/d' /root/.ssh/authorized_keys


Dan Radez's avatar
Dan Radez committed
40
echo "Cleanup Completed"