-i option for setting IPs applies to nodes as well as plcs
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 1 Apr 2008 13:55:56 +0000 (13:55 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 1 Apr 2008 13:55:56 +0000 (13:55 +0000)
system/TestPool.py
system/config_1vnodes.py
system/config_1vservers.py

index 61d24d9..ef52a0d 100644 (file)
@@ -27,9 +27,12 @@ class TestPool:
         self.options=options
         self.busy=[]
 
-    def locate (self, hostname_or_ip):
+    # let's be flexible
+    def locate (self, hostname_or_ip, busy=False):
         for (h,i,u) in self.pool:
-            if h==hostname_or_ip or i==hostname_or_ip:
+            if h.find(hostname_or_ip)>=0  or i.find(hostname_or_ip)>=0 :
+                if busy:
+                    self.busy.append(h)
                 return (h,i,u)
         return None
 
index 08c8b50..a516e96 100644 (file)
@@ -22,7 +22,12 @@ def config (plcs, options):
     all_nodenames = test_mapper.node_names()
     maps = []
     for nodename in all_nodenames:
-        (hostname,ip,mac) = test_pool.next_free()
+        if len(options.ips) != 0:
+            ip=options.ips[0]
+            options.ips=options.ips[1:]
+            (hostname,ip,mac)=test_pool.locate(ip)
+        else:
+            (hostname,ip,mac) = test_pool.next_free()
         node_dict= {'node_fields:hostname':hostname,
                     'network_fields:ip':ip, 
                     # xxx do not et mac as for some reason the qeu nodes don't know about their mac any more
index b6f6d09..d5f4fad 100644 (file)
@@ -6,13 +6,6 @@ from TestPool import TestPool
 onelab_plcs_pool = [ 
     ( 'vplc%02d.inria.fr'%i, '138.96.250.13%d'%i, 'ab:cd:ef:00:00:%02d'%i) for i in range(1,10) ]
 
-# let's be flexible
-def locate (user_provided):
-    global available
-    for (hostname,ip,mac) in available:
-        if hostname.find(user_provided) >=0 or ip.find(user_provided) >=0:
-            return (hostname,ip)
-
 def config (plcs,options):
     
     utils.header ("Turning configuration into a vserver-based one for onelab")
@@ -27,9 +20,15 @@ def config (plcs,options):
     for plc in plcs:
         try:
             if len (options.ips != 0):
-                (hostname,ip,mac)=test_pool.locate(options.ips.pop())
+                ip=options.ips[0]
+                options.ips=options.ips[1:]
+                (hostname,ip,mac)=test_pool.locate(ip)
+                utils.header("Using user-provided %s %s for plc %s"%(
+                        hostname,ip,plc['name']))
             else:
                 (hostname,ip,mac)=test_pool.next_free()
+                utils.header("Using auto-allocated %s %s for plc %s"%(
+                        hostname,ip,plc['name']))
 
             ### rewrite fields in plc
             # compute a helpful vserver name - remove domain in hostname