support for round-robin allocation of vserver addresses - using ping to check for...
[tests.git] / system / config_onelab_vserver.py
1 import utils
2
3 available = [ ( i, 'vnode%02d.inria.fr'%i, '138.96.250.13%d'%i) for i in range(1,10) ]
4
5 def config (plcs,options):
6     available.reverse()
7     for plc in plcs:
8         ### locating the next available hostname (using ping)
9         while True:
10             try:
11                 (i,hostname,ip)=available.pop()
12                 if not utils.check_ping(hostname):
13                     break
14             except:
15                 raise Exception('Cannot find an available IP for %s - exiting'%plc['name'])
16         plc['vservername']=hostname
17         plc['vserverip']=ip
18         plc['name'] = "%s_%02d"%(plc['name'],i)
19         utils.header("Attaching plc %s to vserver %s (%s)"%\
20                          (plc['name'],plc['vservername'],plc['vserverip']))
21         for key in [ 'PLC_DB_HOST',
22                      'PLC_API_HOST',
23                      'PLC_WWW_HOST',
24                      'PLC_BOOT_HOST',
25                      ]:
26             plc[key] = hostname
27
28     return plcs