1 function tear_down_machines() {
2 virtmachines=$(sudo virsh list --name |grep pxe)
3 for virtmachine in $virtmachines; do
4 echo "destroy $virtmachine"
5 sudo virsh destroy $virtmachine
6 if [[ "$?" != "0" ]]; then
7 echo "destroy instance $virtmachine failed"
12 sudo virsh list --all|grep shut|awk '{print $2}'|xargs -n 1 sudo virsh undefine
14 vol_names=$(sudo virsh vol-list default |grep .img | awk '{print $1}')
15 for vol_name in $vol_names; do
16 echo "virsh vol-delete $vol_name"
17 sudo virsh vol-delete $vol_name --pool default
18 if [[ "$?" != "0" ]]; then
19 echo "vol-delete $vol_name failed!"