summaryrefslogtreecommitdiffstats
path: root/ci/cleanvm.sh
blob: f7f062a6fd234ced4fc774d5c34b6876d568d876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

set -ex

#use the below commands if you needs to delete the virtual machine
# also along with envuronment destroy.

echo " Cleanup Started ..."
./clean.sh || true
 
maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`

sudo virsh destroy node1-control || true
sudo virsh destroy node3-control || true
sudo virsh destroy node4-control || true
sudo virsh destroy node2-compute || true
sudo virsh destroy node5-compute || true
sudo virsh undefine node1-control || true
sudo virsh undefine node3-control || true
sudo virsh undefine node4-control || true
sudo virsh undefine node2-compute || true
sudo virsh undefine node5-compute || true
sudo rm -rf  /var/lib/libvirt/images/node1-control.img /var/lib/libvirt/images/node2-compute.img /var/lib/libvirt/images/node3-control.img /var/lib/libvirt/images/node4-control.img /var/lib/libvirt/images/node5-compute.img || true
 
if [[ "$maasver" > "2" ]]; then
    sudo virsh destroy bootstrap || true
    sudo virsh undefine bootstrap || true
    sudo rm -rf  /var/lib/libvirt/images/bootstrap.img || true
fi

echo " Cleanup Finished ..."