blob: 9798ed3148a75857025149713277d04f858f92fb (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/sh
ETC='/etc/libvirt/local/cloudinit'
CONFIG="$ETC/cloudinit.cfg"
# source parameters
[ -e $CONFIG ] && . $CONFIG
vm=$1
if [ -z $vm ]
then
echo "please provide name of VM"
exit 1
fi
if [ -z $VG ]
then
echo "please provide name of volume group in $CONFIG"
exit 1
fi
echo "----- Warning ---- Are you really shure to destroy & delete libvirt guest $vm ?"
echo "Type <yes>"
read answer
if [ "$answer" != 'yes' ]
then
echo "Ok, exiting"
exit 1
fi
echo "Destroying $vm ..."
echo "Please ignore warnings"
echo
virsh destroy $vm
sleep 2
# remove stale device mappings
dmsetup remove $VG-$vm--rootp1
dmsetup remove $VG-$vm--rootp2
lvremove /dev/$VG/$vm-root
lvremove /dev/$VG/$vm-swap
rm -v "/var/lib/libvirt/cloudinit/${vm}-cloudinit_seed.img"
rm -v "/var/lib/libvirt/cloudinit/${vm}01"
rm -v "/var/lib/libvirt/cloudinit/${vm}00"
virsh undefine $vm
|