From ee9426e918691ed07f773e51846f00c56f3fe941 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 1 Apr 2008 13:55:56 +0000 Subject: [PATCH] -i option for setting IPs applies to nodes as well as plcs --- system/TestPool.py | 7 +++++-- system/config_1vnodes.py | 7 ++++++- system/config_1vservers.py | 15 +++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/system/TestPool.py b/system/TestPool.py index 61d24d9..ef52a0d 100644 --- a/system/TestPool.py +++ b/system/TestPool.py @@ -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 diff --git a/system/config_1vnodes.py b/system/config_1vnodes.py index 08c8b50..a516e96 100644 --- a/system/config_1vnodes.py +++ b/system/config_1vnodes.py @@ -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 diff --git a/system/config_1vservers.py b/system/config_1vservers.py index b6f6d09..d5f4fad 100644 --- a/system/config_1vservers.py +++ b/system/config_1vservers.py @@ -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 -- 2.47.0