# OS-dependent ping option (support for macos, for convenience)
ping_timeout_option = None
# checks whether a given hostname/ip responds to ping
- @staticmethod
- def check_ping (hostname):
+ def check_ping (self,hostname):
if not TestPoolIP.ping_timeout_option:
(status,osname) = commands.getstatusoutput("uname -s")
if status != 0:
elif osname == "Darwin":
TestPoolIP.ping_timeout_option="-t"
+ if self.options.verbose:
+ utils.header ("TestPoolIP: pinging %s"%hostname)
command="ping -c 1 %s 1 %s"%(TestPoolIP.ping_timeout_option,hostname)
(status,output) = commands.getstatusoutput(command)
return status == 0
return not TestPoolQemu.busy_qemu(hostname)
# is there a qemu runing on that box already ?
- @staticmethod
- def busy_qemu (hostname):
+ def busy_qemu (self, hostname):
+ if self.options.verbose:
+ utils.header("TestPoolQemu: checking for running qemu instances on %s"%hostname)
command="ssh -o ConnectTimeout=5 root@%s ps -e -o cmd"%hostname
(status,output) = commands.getstatusoutput(command)
# if we fail to run that, let's assume we don't have ssh access, so
def localize (self,plcs,options):
try:
plcs = self.localize_qemus(plcs,options)
- except:
- print 'Could not localize qemus - exiting'
+ except Exception, e:
+ print 'Could not localize qemus','--',e,'--','exiting'
sys.exit(1)
try:
plcs = self.localize_nodes(plcs,options)
- except:
- print 'Could not localize nodes - exiting'
+ except Exception,e:
+ print 'Could not localize nodes','--',e,'--','exiting'
sys.exit(1)
try:
plcs = self.localize_plcs(plcs,options)
- except:
- print 'Could not localize plcs - exiting'
+ except Exception,e:
+ print 'Could not localize plcs','--',e,'--','exiting'
sys.exit(1)
return plcs
--- /dev/null
+## -*-sh-*-
+
+########## locad local defs
+local_defs=~/LocalTestResources.helpers
+if [ -f $local_defs ] ; then
+ source $local_defs
+else
+ echo "you should define qemuboxes and plcboxes in $local_defs"
+ exit
+fi
+
+if [ -z "$qemuboxes" -o -z "$plcboxes" ] ; then
+ echo "you should define qemuboxes and plcboxes in $local_defs"
+ exit
+fi
+
+########## list: from trackers, what should be
+alias list_qemus="head -v ~/tracker-qemus"
+alias list_plcs="head -v ~/tracker-plcs"
+alias list_all="list_qemus ; list_plcs"
+
+########## probe: from real data
+alias probe_qemus='for box in $qemuboxes ; do echo qemu instances in $box ; ssh root@$box pgrep qemu ; done'
+alias probe_plcs='for box in $plcboxes ; do echo plc instances in $box; ssh $box vserver-stat; done'
+alias probe_all="probe_qemus ; probe_plcs"
+
+########## cleanup: stop plc or kill qemus
+function cleanup_qemus () {
+ for box in $qemuboxes ; do
+ echo killing qemu instances in $box
+ ssh root@$box pkill qemu
+ done
+ if [ -f ~/tracker-qemus ] ; then
+ echo ~/cleaning tracker-qemus ; rm ~/tracker-qemus
+ fi
+}
+function cleanup_plcs () {
+ for box in $plcboxes ; do
+ echo stopping vserver instances in $box
+ 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'
+ done
+ if [ -f ~/tracker-plcs ] ; then
+ echo ~/cleaning tracker-plcs
+ rm ~/tracker-plcs
+ fi
+}
+alias cleanup_all="cleanup_qemus ; cleanup_plcs"
+
+########## reboot: reboot the root contexts
+alias reboot_qemus='for box in $qemuboxes; do echo rebooting $box ; ssh root@$box shutdown -r now ; done'
+alias reboot_plcs='for box in $plcboxes; do echo rebooting $box ; ssh root@$box shutdown -r now ; done'
+alias reboot_all="reboot_qemus ; reboot_plcs"
+