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

View File

@ -1,10 +1,14 @@
#!/bin/sh
BUILD=${BUILD:=default}
LAB=${LAB:=0}
## Do not touch below this line
HVN="hvn${LAB}.lab.ipng.ch"
VMS=$(ls -1 build/${BUILD}/${HVN}/)
## Destroy the VMs and bring them back into pristine state
echo "* Restarting VMs from pristine snapshot"
ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; virsh destroy \$VM; zfs rollback ssd-vol0/\${VM}@pristine; 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] Rolling VM back to pristine snapshot"
ssh root@$HVN "zfs rollback ssd-vol0/${VM}@pristine"
done