Created
December 16, 2012 19:00
-
-
Save larsks/4311300 to your computer and use it in GitHub Desktop.
A shell script for deleting a libvirt domain and associated storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Destroy: $1" | |
virsh destroy $1 2> /dev/null | |
for disk in $(virt-disks $1); do | |
pool=$(virsh vol-pool $disk) | |
name=$(virsh vol-info $disk | awk '$1 == "Name:" {print $2}') | |
echo "Delete volume: $disk ($name in $pool)" | |
virsh vol-delete $name $pool | |
done | |
echo "Undefine: $1" | |
virsh undefine $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A small re-factor https://gist.github.com/rabin-io/4011f15fe9a8129dcb3c2f1cc2630ab7