first draft
[tests.git] / system / config_pvnodes.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     ("node-01.test.planet-lab.org","128.112.139.44", "de:ad:be:ef:00:10"),
9     ("node-02.test.planet-lab.org","128.112.139.66", "de:ad:be:ef:00:20"),
10 ]    
11
12 site_dict = {
13     'interface_fields:gateway':'128.112.139.1',
14     'interface_fields:network':'128.112.139.0',
15     'interface_fields:broadcast':'128.112.139.127',
16     'interface_fields:netmask':'255.255.255.128',
17     'interface_fields:dns1': '128.112.136.10',
18     'interface_fields:dns2': '128.112.136.12',
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 } )