blob: dbcc159e651327d10ade86f6bd4dd479b8827a2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/bin/sh
#
# removes all libvirt domains older than 1 day matching given regex
VM_REGEX='$test_'
remove_domain () {
echo "Destroying and undefining $vm"
virsh destroy "$1"
virsh undefine --remove-all-storage --snapshots-metadata "$1"
}
for vm in $(find /etc/libvirt/qemu -maxdepth 1 -type f -mmin +1440 -exec basename -s .xml {} \;)
do
[[ "$vm" =~ "$VM_REGEX" ]] && remove_domain $vm
done
|