support for round-robin allocation of vserver addresses - using ping to check for...
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 18 Jan 2008 09:21:58 +0000 (09:21 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 18 Jan 2008 09:21:58 +0000 (09:21 +0000)
system/TestMain.py
system/config_onelab.py
system/config_onelab_vserver.py
system/utils.py

index 8a61956..c4be4c8 100755 (executable)
@@ -74,6 +74,8 @@ steps refer to a method in TestPlc or to a step_* module"""%(TestMain.default_bu
         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]                        
index db874f9..eca4b2e 100644 (file)
@@ -177,7 +177,7 @@ def slices ():
 
 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
index 700b320..d02f575 100644 (file)
@@ -1,21 +1,28 @@
-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
index 2219848..589f77a 100644 (file)
@@ -1,6 +1,7 @@
 # $Id$
 import time
 import os
+import commands
 import pprint
 
 # how could this accept a list again ?
@@ -18,3 +19,20 @@ def system(command):
     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