3 from TestPool import TestPoolIP
5 onelab_plcs_ip_pool = [
6 ( 'vplc%02d.inria.fr'%i,
7 '138.96.255.%d'%(200+i),
8 '02:34:56:00:ee:%02d'%i) for i in range(1,21) ]
10 def config (plcs,options):
12 utils.header ("Turning configuration into a vserver-based one for onelab")
14 ip_pool = TestPoolIP (onelab_plcs_ip_pool,options)
20 ip_or_hostname=options.ips_plc.pop()
21 (hostname,ip,mac)=ip_pool.locate_entry(ip_or_hostname)
23 utils.header("Using user-provided %s %s for plc %s"%(
24 hostname,ip_or_hostname,plc['name']))
26 (hostname,ip,mac)=ip_pool.next_free()
28 utils.header("Using auto-allocated %s %s for plc %s"%(
29 hostname,ip,plc['name']))
31 ### rewrite fields in plc
32 # compute a helpful vserver name - remove domain in hostname
33 simplehostname=hostname.split('.')[0]
34 vservername = options.buildname
36 vservername = "%s-%s" % (vservername,simplehostname)
39 vservername = "%s-%d-%s" % (vservername,plc_counter,simplehostname)
41 plc['vservername']=vservername
43 plc['name'] = "%s_%s"%(plc['name'],simplehostname)
44 utils.header("Attaching plc %s to vserver %s (%s)"%(
45 plc['name'],plc['vservername'],plc['vserverip']))
46 for key in [ 'PLC_DB_HOST', 'PLC_API_HOST', 'PLC_WWW_HOST', 'PLC_BOOT_HOST',]:
50 raise Exception('Cannot find an available IP for %s - exiting'%plc['name'])