use alias name for the plc box
[tests.git] / system / config_1testbox.py
1 import sys
2
3 from TestMapper import TestMapper
4 from TestPool import TestPoolQemu
5
6 # a small qemu pool for now
7 onelab_qemus_pool = [ ( 'testqemu%d.onelab.eu'%i, None, None) for i in range(1,4) ]
8     
9 def config (plcs, options):
10
11     # all plcs on the same vserver box
12     plc_box   ='testbox-plc.onelab.eu'
13     # informative
14     label=options.personality.replace("linux","")
15
16     # all qemus on a unique pool of 64bits boxes
17     node_map = []
18     qemu_pool = TestPoolQemu (onelab_qemus_pool,options)
19     for index in range(options.size):
20         index += 1
21         if options.ips_qemu:
22             ip_or_hostname=options.ips_qemu.pop()
23             (hostname,ip,unused)=qemu_pool.locate_entry(ip_or_hostname)
24         else:
25             (hostname,ip,unused) = qemu_pool.next_free()
26         node_map += [ ('node%d'%index, {'host_box':hostname},) ]
27
28     mapper = {'plc': [ ('*' , {'hostname':plc_box,
29                                'PLC_DB_HOST':plc_box,
30                                'PLC_API_HOST':plc_box,
31                                'PLC_BOOT_HOST':plc_box,
32                                'PLC_WWW_HOST':plc_box,
33                                'name':'%s-'+label } ) 
34                        ],
35               'node': node_map,
36               }
37     
38     return TestMapper(plcs,options).map(mapper)