Test framework reworked for
[tests.git] / system / config-onelab-chroot.py
1 # a configuration module is expected:
2 # (*) to define a config method
3 # (*) that takes two arguments
4 #     (**) the current set of plc_specs as output by the preceding config modules
5 #     (**) TestMain options field
6 # (*) and that returns the new set of plc_specs
7
8 onelab="one-lab.org"
9
10 # use a model that contains "vmware" to get the node actually started
11 def nodes():
12     return [ {'node_fields': {'hostname': 'test1.one-lab.org',
13                               'model':'vmware/minhw'},
14               'owner' : 'pi',
15               'network_fields': { 'method':'static',
16                                   'type':'ipv4',
17                                   'ip':'192.168.132.128',
18                                   'gateway':'192.168.132.1',
19                                   'network':'192.168.132.0',
20                                   'broadcast':'192.168.132.255',
21                                   'netmask':'255.255.255.0',
22                                   'dns1': '192.168.132.2',
23                                   },
24               },
25              { 'node_fields': {'hostname':'test2.one-lab.org',
26                                'model':'vmware/minhw'},
27                'owner' : 'tech',
28                'network_fields': {'method':'static',
29                                   'type':'ipv4',
30                                   'ip':'192.168.132.130',
31                                   'gateway':'192.168.132.1',
32                                   'network':'192.168.132.0',
33                                   'broadcast':'192.168.132.255',
34                                   'netmask':'255.255.255.0',
35                                   'dns1': '192.168.132.2',
36                                   },
37                },
38              ]
39
40 def all_nodenames ():
41     return [ node['node_fields']['hostname'] for node in nodes()]
42
43 def users (domain=onelab) :
44     return [ {'name' : 'pi', 'keynames' : [ 'key1' ],
45               'user_fields' : {'first_name':'PI', 'last_name':'PI',
46                                'enabled':'True',
47                                'email':'fake-pi1@%s'%domain,
48                                'password':'testpi'},
49               'roles':['pi']},
50              {'name' : 'tech', 'keynames' : [ 'key1' ],
51               'user_fields' : {'first_name':'Tech', 'last_name':'Tech',
52                                'enabled':'true',
53                                'email':'fake-tech1@%s'%domain,
54                                'password':'testtech'},
55               'roles':['tech']},
56              {'name':'user', 'keynames' : [ 'key1' ],
57               'user_fields' : {'first_name':'User', 'last_name':'User',
58                                'enabled':'true',
59                                'email':'fake-user1@%s'%domain,
60                                'password':'testuser'},
61               'roles':['user']},
62              {'name':'techuser', 'keynames' : [ 'key1' ],
63               'user_fields' : {'first_name':'UserTech', 'last_name':'UserTech',
64                                'enabled':'true',
65                                'email':'fake-tech2@%s'%domain,
66                                'password':'testusertech'},
67               'roles':['tech','user']},
68              {'name':'pitech', 'keynames' : [ 'key1' ],
69               'user_fields' : {'first_name':'PiTech',
70                                'last_name':'PiTech',
71                                'enabled':'true',
72                                'email':'fake-pi2@%s'%domain,
73                                'password':'testusertech'},
74               'roles':['pi','tech']},
75              ]
76
77 def all_usernames ():
78     return [ user['name'] for user in users()]
79
80 def sites ():
81     return [ {'site_fields' : {'name':'mainsite',
82                                'login_base':'main',
83                                'abbreviated_name':'PLanettest',
84                                'max_slices':100,
85                                'url':'http://onelab-test.inria.fr',
86                                },
87               'address_fields' : {'line1':'route des lucioles',
88                                   'city':'sophia',
89                                   'state':'fr',
90                                   'postalcode':'06600',
91                                   'country':'france',
92                                   },
93               'users' : users(),
94               'nodes': nodes(),
95             }]
96
97 def keys ():
98     return [ {'name': 'key1',
99               'key_fields' : {'key_type':'ssh',
100                               'key':'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4jNj8yT9ieEc6nSJz/ESu4fui9WrJ2y/MCfqIZ5WcdVKhBFUYyIenmUaeTduMcSqvoYRQ4QnFR1BFdLG8XR9D6FWZ5zTKUgpkew22EVNeqai4IXeWYKyt1Qf3ehaz9E3o1PG/bmQNIM6aQay6TD1Y4lqXI+eTVXVQev4K2fixySjFQpp9RB4UHbeA8c28yoa/cgAYHqCqlvm9uvpGMjgm/Qa4M+ZeO7NdjowfaF/wF4BQIzVFN9YRhvQ/d8WDz84B5Pr0J7pWpaX7EyC4bvdskxl6kmdNIwIRcIe4OcuIiX5Z9oO+7h/chsEVJWF4vqNIYlL9Zvyhnr0hLLhhuk2bw== root@onelab-test.inria.fr'}}
101              ]
102
103 def initscripts(): 
104     return [ { 'name' : 'test1',
105                'initscript_fields' : { 'enabled' : True,
106                                        'name':'Test1',
107                                        'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 1; date) > /tmp/initscript1.log \n ',
108                                        }},
109              { 'name' : 'test2',
110                'initscript_fields' : { 'enabled' : True,
111                                        'name':'Test2',
112                                        'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/initscript2.log \n ',
113                                        }},
114              ]
115
116 def slices ():
117     both = [ { 'slice_fields': {'name':'main_slicetest1',
118                                 'instantiation':'plc-instantiated',
119                                 'url':'http://foo@ffo.com',
120                                 'description':'testslice the first slice for the site testsite',
121                                 'max_nodes':2
122                                 },
123                'usernames' : [ 'pi','tech','techuser' ],
124                'nodenames' : all_nodenames(),
125                'initscriptname' : 'test1',
126                'sitename' : 'main',
127                'owner' : 'pi',
128                },
129              { 'slice_fields': {'name':'main_slicetest2',
130                                 'instantiation':'plc-instantiated',
131                                 'url':'http://foo2@ffo2.com',
132                                 'description':'testslice the second slice for the site testsite',
133                                 'max_nodes':100
134                                 },
135                'usernames' : [ 'user', 'pitech' ],
136                'nodenames' : all_nodenames(),
137                'initscriptname' : 'test2',
138                'sitename' : 'main',
139                'owner' : 'pi',
140                }]
141     # I suspect the check_slices stuff to work improperly with 2 slices
142     return both
143
144 def plc () :
145     return { 
146         'name' : 'onelab-chroot',
147         # as of yet, not sure we can handle foreign hosts, but this is required though
148         'hostname' : 'localhost',
149         # use this to run in a vserver
150         # 'vserver': '138.96.250.131'
151         'role' : 'root',
152         'PLC_ROOT_USER' : 'root@onelab-test.inria.fr',
153         'PLC_ROOT_PASSWORD' : 'test++',
154         'PLC_NAME' : 'TestLab',
155         'PLC_MAIL_ENABLED':'true',
156         'PLC_MAIL_SUPPORT_ADDRESS' : 'mohamed-amine.chaoui@sophia.inria.fr',
157         'PLC_DB_HOST' : 'onelab-test.inria.fr',
158         'PLC_API_HOST' : 'onelab-test.inria.fr',
159         'PLC_WWW_HOST' : 'onelab-test.inria.fr',
160         'PLC_BOOT_HOST' : 'onelab-test.inria.fr',
161         'PLC_NET_DNS1' : '138.96.0.10',
162         'PLC_NET_DNS2' : '138.96.0.11',
163         'sites' : sites(),
164         'keys' : keys(),
165         'initscripts': initscripts(),
166         'slices' : slices(),
167     }
168
169 def config (plc_specs,options):
170     return plc_specs + [ plc() ]
171