4743d1130b12cce11ac94bb87ddc22bf43456a52
[tests.git] / system / helpers.aliases
1 ## -*-sh-*-
2
3 ########## locad local defs
4 local_defs=~/LocalTestResources.helpers
5 if [ -f $local_defs ] ; then 
6     source $local_defs
7 else
8     echo "you should define qemuboxes and plcboxes in $local_defs"
9     exit
10 fi
11
12 if [ -z "$qemuboxes" -o -z "$plcboxes" ] ; then
13     echo "you should define qemuboxes and plcboxes in $local_defs"
14     exit
15 fi
16
17 ########## list: from trackers, what should be
18 alias list_qemus="head -v ~/tracker-qemus"
19 alias list_plcs="head -v ~/tracker-plcs"
20 alias list_all="list_qemus ; list_plcs"
21
22 ########## probe: from real data
23 alias probe_qemus='for box in $qemuboxes ; do echo qemu instances in $box ; ssh root@$box pgrep qemu ; done'
24 alias probe_plcs='for box in $plcboxes ; do echo plc instances in $box; ssh $box vserver-stat; done'
25 alias probe_all="probe_qemus ; probe_plcs"
26
27 ########## cleanup: stop plc or kill qemus
28 function cleanup_qemus () {
29     for box in $qemuboxes ; do 
30         echo killing qemu instances in $box
31         ssh root@$box pkill qemu
32     done
33     if [ -f ~/tracker-qemus ] ; then 
34         echo ~/cleaning tracker-qemus ; rm ~/tracker-qemus 
35     fi
36 }
37 function cleanup_plcs () { 
38     for box in $plcboxes ; do 
39         echo stopping vserver instances in $box 
40         ssh root@$box 'cd /vservers ; for vsname in *; do echo -n "stop $vsname y/[n] ? "; read answer ; case $answer in nN) echo skipping $vsname ;; *) vserver $vsname stop ;; esac; done'
41     done
42     if [ -f ~/tracker-plcs ] ; then 
43         echo ~/cleaning tracker-plcs
44         rm ~/tracker-plcs
45     fi
46 }
47 alias cleanup_all="cleanup_qemus ; cleanup_plcs"
48
49 ########## reboot: reboot the root contexts 
50 alias reboot_qemus='for box in $qemuboxes; do echo rebooting $box ; ssh root@$box shutdown -r now ; done'
51 alias reboot_plcs='for box in $plcboxes; do echo rebooting $box ; ssh root@$box shutdown -r now ; done'
52 alias reboot_all="reboot_qemus ; reboot_plcs"
53