Add a virshall
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.
This commit is contained in:
16
README.md
16
README.md
@ -84,9 +84,12 @@ shut down the VMs and destroy the clones.
|
|||||||
|
|
||||||
```
|
```
|
||||||
lab:~/src/lab$ ./generate --host hvn0.lab.ipng.ch --overlay default
|
lab:~/src/lab$ ./generate --host hvn0.lab.ipng.ch --overlay default
|
||||||
lab:~/src/lab$ lab=0 ./destroy ## remove VMs and ZFS clones
|
lab:~/src/lab$ LAB=0 ./destroy ## remove VMs and ZFS clones
|
||||||
lab:~/src/lab$ lab=0 ./create ## create ZFS 'pristine' snapshot and start VMs
|
lab:~/src/lab$ LAB=0 ./create ## create ZFS 'pristine' snapshot
|
||||||
lab:~/src/lab$ lab=0 ./pristine ## return the lab to the latest 'pristine' snapshot
|
lab:~/src/lab$ LAB=0 ./virshall start ## Start the VMs
|
||||||
|
lab:~/src/lab$ LAB=0 ./virshall shutdown ## Gracefully stop the VMs
|
||||||
|
lab:~/src/lab$ LAB=0 ./virshall destroy ## Hard poweroff the VMs
|
||||||
|
lab:~/src/lab$ LAB=0 ./pristine ## return the lab to the latest 'pristine' snapshot
|
||||||
```
|
```
|
||||||
|
|
||||||
### Generate
|
### Generate
|
||||||
@ -111,7 +114,7 @@ clones are destroyed. Obviously this is the most dangerous operation of the bunc
|
|||||||
of the lab is that the VMs can be re-created off of a stable base image and a generated build.
|
of the lab is that the VMs can be re-created off of a stable base image and a generated build.
|
||||||
|
|
||||||
```
|
```
|
||||||
lab:~/src/lab$ lab=0 ./destroy ## remove VMs and ZFS clones on hvn0.lab.ipng.ch
|
lab:~/src/lab$ LAB=0 ./destroy ## remove VMs and ZFS clones on hvn0.lab.ipng.ch
|
||||||
```
|
```
|
||||||
|
|
||||||
### Create
|
### Create
|
||||||
@ -126,7 +129,7 @@ Typically, it's necessary to destroy/create, only when the build or the base ima
|
|||||||
the lab can be brought back into a _factory default_ state by rolling back to the `pristine` snapshot.
|
the lab can be brought back into a _factory default_ state by rolling back to the `pristine` snapshot.
|
||||||
|
|
||||||
```
|
```
|
||||||
lab:~/src/lab$ lab=0 ./create ## create ZFS 'pristine' snapshots and start VMs
|
lab:~/src/lab$ LAB=0 ./create ## create ZFS 'pristine' snapshots and start VMs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Pristine
|
### Pristine
|
||||||
@ -137,5 +140,6 @@ brought back into a default state by rolling back the disks to the `pristine` sn
|
|||||||
the virtual machines.
|
the virtual machines.
|
||||||
|
|
||||||
```
|
```
|
||||||
lab:~/src/lab$ lab=0 ./pristine ## return the lab to the latest 'pristine' snapshot
|
lab:~/src/lab$ LAB=0 ./pristine ## return the lab to the latest 'pristine' snapshot
|
||||||
|
lab:~/src/lab$ LAB=0 ./vishall start ## Start the VMs
|
||||||
```
|
```
|
||||||
|
9
create
9
create
@ -15,7 +15,7 @@
|
|||||||
## * Unmount the staging directories
|
## * Unmount the staging directories
|
||||||
## * Start the VMs
|
## * Start the VMs
|
||||||
|
|
||||||
BASE=${BASE:=ssd-vol0/hvn0.chbtl0.ipng.ch/ssd-vol0/vpp-proto-disk0@20221019-release}
|
BASE=${BASE:=ssd-vol0/hvn0.chbtl0.ipng.ch/ssd-vol0/vpp-proto-disk0@20221022-release}
|
||||||
BUILD=${BUILD:=default}
|
BUILD=${BUILD:=default}
|
||||||
LAB=${LAB:=0}
|
LAB=${LAB:=0}
|
||||||
|
|
||||||
@ -39,10 +39,3 @@ ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; chown -R r
|
|||||||
|
|
||||||
echo "* Unmounting and snapshotting pristine state"
|
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"
|
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; LAB=$LAB $LABDIR/ovs-config.sh"
|
|
||||||
|
11
pristine
11
pristine
@ -1,17 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
BUILD=${BUILD:=default}
|
|
||||||
LAB=${LAB:=0}
|
LAB=${LAB:=0}
|
||||||
|
|
||||||
## Do not touch below this line
|
## Do not touch below this line
|
||||||
LABDIR=/var/lab
|
|
||||||
STAGING=$LABDIR/staging
|
|
||||||
HVN="hvn${LAB}.lab.ipng.ch"
|
HVN="hvn${LAB}.lab.ipng.ch"
|
||||||
|
|
||||||
## Bring back into pristine state
|
## Destroy the VMs and bring them back into pristine state
|
||||||
echo "* Restarting VMs from pristine snapshot"
|
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"
|
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"
|
||||||
|
|
||||||
echo "* Committing OVS config"
|
|
||||||
scp overlays/$BUILD/ovs-config.sh root@$HVN:$LABDIR
|
|
||||||
ssh root@$HVN "set -x; $LABDIR/ovs-config.sh"
|
|
||||||
|
23
virshall
Executable file
23
virshall
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
BUILD=${BUILD:=default}
|
||||||
|
LAB=${LAB:=0}
|
||||||
|
|
||||||
|
## Do not touch below this line
|
||||||
|
LABDIR=/var/lab
|
||||||
|
STAGING=$LABDIR/staging
|
||||||
|
HVN="hvn${LAB}.lab.ipng.ch"
|
||||||
|
CMD=$1
|
||||||
|
|
||||||
|
[ "$CMD" != "start" -a "$CMD" != "shutdown" -a "$CMD" != "destroy" ] && {
|
||||||
|
echo "Usage: LAB=0 ./virshall start|shutdown|destroy"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "* Executing $CMD against all VMs on lab $LAB"
|
||||||
|
ssh root@$HVN "set -x; for node in 0 1 2 3; do VM=vpp${LAB}-\${node}; virsh $CMD \$VM; done"
|
||||||
|
|
||||||
|
[ "$CMD" = "start" ] && {
|
||||||
|
echo "* Committing OVS config"
|
||||||
|
scp overlays/$BUILD/ovs-config.sh root@$HVN:$LABDIR
|
||||||
|
ssh root@$HVN "set -x; $LABDIR/ovs-config.sh"
|
||||||
|
}
|
Reference in New Issue
Block a user