IP renumbering
[tests.git] / system / config_1vnodes.py
1 # map all nodes onto the avail. pool
2
3 import utils
4 from TestMapper import TestMapper
5 from TestPool import TestPoolIP
6
7 onelab_nodes_ip_pool = [ 
8     ( 'vnode%02d.inria.fr'%i, 
9       '138.96.255.%d'%(230+i), 
10       '02:34:56:00:00:%02d'%i) for i in range(1,10) ]
11
12 site_dict = {
13     'interface_fields:gateway':'138.96.248.250',
14     'interface_fields:network':'138.96.0.0',
15     'interface_fields:broadcast':'138.96.255.255',
16     'interface_fields:netmask':'255.255.0.0',
17     'interface_fields:dns1': '138.96.0.10',
18     'interface_fields:dns2': '138.96.0.11',
19 }
20
21 def config (plcs, options):
22     
23     ip_pool = TestPoolIP (onelab_nodes_ip_pool,options)
24     test_mapper = TestMapper (plcs, options)
25
26     all_nodenames = test_mapper.node_names()
27     maps = []
28     for nodename in all_nodenames:
29         if options.ips_node:
30             ip_or_hostname=options.ips_node.pop()
31             (hostname,ip,mac)=ip_pool.locate_entry(ip_or_hostname)
32         else:
33             (hostname,ip,mac) = ip_pool.next_free()
34         utils.header('Attaching node %s to %s (%s)'%(nodename,hostname,ip))
35         node_dict= {'node_fields:hostname':hostname,
36                     'interface_fields:ip':ip, 
37                     'interface_fields:mac':mac,
38                     }
39     
40         node_dict.update(site_dict)
41         maps.append ( ( nodename, node_dict) )
42
43     plc_map = [ ( '*' , { 'PLC_NET_DNS1' : site_dict [ 'interface_fields:dns1' ],
44                         'PLC_NET_DNS2' : site_dict [ 'interface_fields:dns2' ], } ) ]
45
46     return test_mapper.map ({'node': maps, 'plc' : plc_map } )