From 85883eaefb229a56ff7b968d6e08c2dfb5af174d Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 18 Oct 2022 22:53:18 +0200 Subject: [PATCH] Flesh out create/destroy/pristine a little bit --- create | 34 ++++++++++++++++++++++++++++++++++ destroy | 14 ++++++++++++++ pristine | 10 ++++++++++ 3 files changed, 58 insertions(+) mode change 100644 => 100755 create mode change 100644 => 100755 destroy create mode 100755 pristine diff --git a/create b/create old mode 100644 new mode 100755 index badac96..1b8bcd6 --- a/create +++ b/create @@ -1,3 +1,5 @@ +#!/bin/sh + ## Using SSH: ## * Log in to hypervisor, retrieve list of running VMs ## * Log in to hypervisor, retrieve list of ZFS volumes @@ -12,3 +14,35 @@ ## * Rsync over our build/$(overlay)/$(hypervisor)/* ## * Unmount the staging directories ## * Start the VMs + +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 +LABDIR=/var/lab +STAGING=$LABDIR/staging +HVN="hvn${LAB}.lab.ipng.ch" + +echo "* Cloning base" +ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; mkdir -p $STAGING/\$VM; zfs clone $BASE ssd-vol0/\$VM; done" +sleep 1 + +echo "* Mounting in staging" +ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; mount /dev/zvol/ssd-vol0/\$VM-part1 $STAGING/\$VM; done" + +echo "* Rsyncing build" +rsync -avugP build/$BUILD/$HVN/ root@hvn${LAB}.lab.ipng.ch:$STAGING + +echo "* Setting permissions" +ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; chown -R root. $STAGING/\$VM/root; done" + +echo "* Unmounting and snapshotting pristine state" +ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; umount $STAGING/\$VM; zfs snapshot ssd-vol0/\${VM}@pristine; done" + +echo "* Starting VMs" +ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; virsh start \$VM; done" + +echo "* Committing OVS config" +scp overlays/$BUILD/ovs-config.sh root@$HVN:$LABDIR +ssh root@$HVN "set -x; $LABDIR/ovs-config.sh" diff --git a/destroy b/destroy old mode 100644 new mode 100755 index 9c1fe4d..e77d26a --- a/destroy +++ b/destroy @@ -1,3 +1,5 @@ +#!/bin/sh + ## Using SSH: ## * Log in to hypervisor, retrieve list of running VMs ## * Log in to hypervisor, retrieve list of ZFS volumes @@ -6,3 +8,15 @@ ## * 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} +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" + +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" diff --git a/pristine b/pristine new file mode 100755 index 0000000..ea176d6 --- /dev/null +++ b/pristine @@ -0,0 +1,10 @@ +#!/bin/sh + +LAB=${LAB:=0} + +## Do not touch below this line +HVN="hvn${LAB}.lab.ipng.ch" + +## Bring 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; virsh start \$VM; done"