virshall can start, shutdown or destroy all VMs on a hypervisor LAB so I can remove 'start' from create and pristine; sometimes it is useful to only create (but not start) the LABs. Similarly, sometimes bringing the LAB into pristine state, but without restarting the VMs, is useful.
42 lines
1.6 KiB
Bash
Executable File
42 lines
1.6 KiB
Bash
Executable File
#!/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 any of these exist, bail and require the user to run ./destroy first
|
|
##
|
|
##
|
|
## * Log in to the hypervisor, and:
|
|
## * Clone the base image to all VM names (ssd-vol0/vpp0-[0-3])
|
|
## * Mount these in a staging directory
|
|
## * 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@20221022-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"
|