if len(self.args) == 0:
if self.options.all_steps:
self.options.steps=TestMain.default_steps
+ elif self.options.dry_run:
+ self.options.steps=TestMain.default_steps
else:
print 'No step found (do you mean -a ? )'
print "Run %s --help for help"%sys.argv[0]
def plc () :
return {
- 'name' : 'onelab',
+ 'name' : 'onelabtest',
# as of yet, not sure we can handle foreign hosts, but this is required though
'hostname' : 'localhost',
# set these two items to run within a vserver
-available = [ ('vbuild1.inria.fr','138.96.250.131'),
- ('vbuild2.inria.fr','138.96.250.132'),
- ('vbuild3.inria.fr','138.96.250.133'),
- ('vbuild4.inria.fr','138.96.250.134'),
- ]
+import utils
+
+available = [ ( i, 'vnode%02d.inria.fr'%i, '138.96.250.13%d'%i) for i in range(1,10) ]
def config (plcs,options):
available.reverse()
for plc in plcs:
- # get next slot -- xxx shoud check for running ones
- (name,ip)=available.pop()
- plc['vservername']=name
+ ### locating the next available hostname (using ping)
+ while True:
+ try:
+ (i,hostname,ip)=available.pop()
+ if not utils.check_ping(hostname):
+ break
+ except:
+ raise Exception('Cannot find an available IP for %s - exiting'%plc['name'])
+ plc['vservername']=hostname
plc['vserverip']=ip
+ plc['name'] = "%s_%02d"%(plc['name'],i)
+ utils.header("Attaching plc %s to vserver %s (%s)"%\
+ (plc['name'],plc['vservername'],plc['vserverip']))
for key in [ 'PLC_DB_HOST',
'PLC_API_HOST',
'PLC_WWW_HOST',
'PLC_BOOT_HOST',
]:
- plc[key] = name
+ plc[key] = hostname
return plcs
# $Id$
import time
import os
+import commands
import pprint
# how could this accept a list again ?
print "+",now
return os.system("set -x; " + command)
+# checks whether a given hostname/ip responds to ping
+ping_timeout_option = None
+def check_ping (hostname):
+ # check OS (support for macos)
+ global ping_timeout_option
+ if not ping_timeout_option:
+ (status,osname) = commands.getstatusoutput("uname -s")
+ if status != 0:
+ raise Exception, "Cannot figure your OS name"
+ if osname == "Linux":
+ ping_timeout_option="-w"
+ elif osname == "Darwin":
+ ping_timeout_option="-t"
+
+ command="ping -c 1 %s 1 %s"%(ping_timeout_option,hostname)
+ (status,output) = commands.getstatusoutput(command)
+ return status == 0