forked from fultonj/oooq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvms.sh
executable file
·45 lines (45 loc) · 1.51 KB
/
vms.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
# Filename: vms.sh
# Description: runs commands as stack@virthost
# Time-stamp: <2017-02-03 20:23:36 jfulton>
# -------------------------------------------------------
# another crude but effective wrapper for the lazy
# -------------------------------------------------------
case "$1" in
undercloud)
case "$2" in
stop)
cmd='virsh shutdown undercloud'
;;
start)
cmd='virsh start undercloud'
;;
suspend)
cmd='virsh suspend undercloud'
;;
resume)
cmd='virsh resume undercloud'
;;
*)
cmd="virsh list --all"
esac
;;
resume)
cmd='for vm in $(virsh list --all | awk {"print \$2"} | egrep -v "Name|^$"); do echo "running resume $vm"; virsh resume $vm; done'
;;
stop)
cmd='for vm in $(virsh list --all | awk {"print \$2"} | egrep -v "Name|^$"); do echo "running shutdown $vm"; virsh shutdown $vm; done'
echo $cmd
;;
suspend)
cmd='for vm in $(virsh list --all | awk {"print \$2"} | egrep -v "Name|^$"); do echo "running suspend $vm"; virsh suspend $vm; done'
;;
start)
cmd='for vm in $(virsh list --all | awk {"print \$2"} | egrep -v "Name|^$"); do echo "running start $vm"; virsh start $vm; done'
;;
*)
cmd="virsh list --all"
esac
# -------------------------------------------------------
export SSH_ENV=~/.quickstart/ssh.config.ansible
ssh -q -F $SSH_ENV virthost "$cmd"