3 from TestPool import TestPool
5 # the pool of IP addresses available - from 01 to 09
7 # ( 'vplc%02d.inria.fr'%i, '138.96.250.13%d'%i, '02:34:56:00:ee:%02d'%i) for i in range(1,10) ]
8 # vplc09 is reserved for a fixed myplc - from 01 to 08
10 ( 'vplc%02d.inria.fr'%i, '138.96.255.%d'%(200+i), '02:34:56:00:ee:%02d'%i) for i in range(1,21) ]
12 def config (plcs,options):
14 utils.header ("Turning configuration into a vserver-based one for onelab")
16 test_pool = TestPool (onelab_plcs_pool,options)
18 if len(options.plc_ips) != 0:
19 utils.header('Using user-provided IPS:\nplc_ips=%r'%options.plc_ips)
20 options.plc_ips.reverse()
25 if len(options.plc_ips) != 0:
27 options.plc_ips=options.plc_ips[1:]
28 (hostname,ip,mac)=test_pool.locate(ip)
29 utils.header("Using user-provided %s %s for plc %s"%(
30 hostname,ip,plc['name']))
32 (hostname,ip,mac)=test_pool.next_free()
33 utils.header("Using auto-allocated %s %s for plc %s"%(
34 hostname,ip,plc['name']))
36 ### rewrite fields in plc
37 # compute a helpful vserver name - remove domain in hostname
38 simplehostname=hostname.split('.')[0]
39 vservername = options.buildname
41 vservername = "%s-%s" % (vservername,simplehostname)
44 vservername = "%s-%d-%s" % (vservername,plc_counter,simplehostname)
46 plc['vservername']=vservername
48 plc['name'] = "%s_%s"%(plc['name'],simplehostname)
49 utils.header("Attaching plc %s to vserver %s (%s)"%(
50 plc['name'],plc['vservername'],plc['vserverip']))
51 for key in [ 'PLC_DB_HOST', 'PLC_API_HOST', 'PLC_WWW_HOST', 'PLC_BOOT_HOST',]:
55 raise Exception('Cannot find an available IP for %s - exiting'%plc['name'])