Add lab-build snippets and executing them in 'create'. Refactor create/destroy/pristine; also, only virsh destroy VMs if they are 'running'

This commit is contained in:
Pim van Pelt
2023-05-06 12:41:01 +00:00
parent bd4c76689d
commit 72245529a2
17 changed files with 102 additions and 24 deletions

12
destroy
View File

@ -10,13 +10,17 @@
## * 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"
echo "* Destroying VMs"
ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; virsh destroy \$VM; done"
VMS=$(ls -1 build/${BUILD}/${HVN}/)
echo "* Destroying ZFS datasets"
ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; zfs destroy -r ssd-vol0/\$VM; done"
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