#!/bin/sh ## Using SSH: ## * Log in to hypervisor, retrieve list of running VMs ## * Log in to hypervisor, retrieve list of ZFS volumes ## * List any VM matching spec ^vpp[\d]+-[\d+]$ ## * List any ZFS datasets matching matching spec ^ssd-vol0/vpp[\d]+-[\d+]$ ## * If --force is set: ## * Destroy matching VMs ## * Recursively delete any matching ZFS datasets BASE=${BASE:=ssd-vol0/hvn0.chbtl0.ipng.ch/ssd-vol0/vpp-proto-disk0@20221018-release} BUILD=${BUILD:=default} LAB=${LAB:=0} ## Do not touch below this line HVN="hvn${LAB}.lab.ipng.ch" VMS=$(ls -1 build/${BUILD}/${HVN}/) for VM in $VMS; do echo "[$VM] Destroying VM" ssh root@$HVN "/usr/bin/virsh list --all | grep $VM.*running >/dev/null && virsh destroy $VM" echo "[$VM] Destroying ZFS datasets" ssh root@$HVN "zfs destroy -r ssd-vol0/$VM" done