3 from TestPool import TestPoolIP
5 # using vplc01 .. vplc15 - keep [16,17,18] for 4.2 and 19 and 20 for long-haul tests
6 onelab_plcs_ip_pool = [
7 ( 'vplc%02d.inria.fr'%i,
8 '138.96.255.%d'%(200+i),
9 '02:34:56:00:ee:%02d'%i) for i in range(1,16) ]
11 def config (plcs,options):
13 utils.header ("Turning configuration into a vserver-based one for onelab")
15 ip_pool = TestPoolIP (onelab_plcs_ip_pool,options)
21 ip_or_hostname=options.ips_plc.pop()
22 (hostname,ip,mac)=ip_pool.locate_entry(ip_or_hostname)
24 utils.header("Using user-provided %s %s for plc %s"%(
25 hostname,ip_or_hostname,plc['name']))
27 (hostname,ip,mac)=ip_pool.next_free()
29 utils.header("Using auto-allocated %s %s for plc %s"%(
30 hostname,ip,plc['name']))
32 ### rewrite fields in plc
33 # compute a helpful vserver name - remove domain in hostname
34 simplehostname=hostname.split('.')[0]
35 vservername = options.buildname
37 vservername = "%s-%s" % (vservername,simplehostname)
40 vservername = "%s-%d-%s" % (vservername,plc_counter,simplehostname)
42 plc['vservername']=vservername
44 plc['name'] = "%s_%s"%(plc['name'],simplehostname)
45 utils.header("Attaching plc %s to vserver %s (%s)"%(
46 plc['name'],plc['vservername'],plc['vserverip']))
47 for key in [ 'PLC_DB_HOST', 'PLC_API_HOST', 'PLC_WWW_HOST', 'PLC_BOOT_HOST',]:
51 raise Exception('Cannot find an available IP for %s - exiting'%plc['name'])