do not create the 3rd slice that is omf-friendly
[tests.git] / system / config_default.py
1 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
2 # Copyright (C) 2010 INRIA 
3 #
4 # a configuration module is expected:
5 # (*) to define a config method
6 # (*) that takes two arguments
7 #     (**) the current set of plc_specs as output by the preceding config modules
8 #     (**) TestMain options field
9 # (*) and that returns the new set of plc_specs
10
11 # values like 'hostname', 'ip' and the like are rewritten later with a TestPool object
12
13 domain="onelab.eu"
14
15 ### for the sfa dual setup
16 def login_base (index): 
17     if index==1: return 'inri'
18     elif index==2: return 'princ'
19     # index=3=>'sitea'  4=>'siteb' 
20     else: return 'site%s'%chr(index+94)
21
22 def sfa_login_base (index, rspec_style):
23     return "sfa%s"%(rspec_style)
24
25 def sfa_root (index):
26     # use plt (planetlab test) instead of pl
27     # otherwise a triangular test ends up with 'plc'
28     # plta, pltb, ...
29     return 'plt%s'%chr(index+96)
30
31 def nodes(options,index):
32     return [{'name':'node%d'%index,
33              'node_fields':             {'hostname': 'deferred-nodename%d'%index,
34                                          'model':'qemu/minhw', } ,
35              'host_box': 'deferred-node-hostbox-%d'%index,
36              'owner' : 'pi',
37              'nodegroups' : 'mynodegroup',
38              'interface_fields':        { 'method':'static',
39                                           'type':'ipv4',
40                                           'ip':'xxx-deferred-xxx',
41                                           'gateway':'xxx-deferred-xxx',
42                                           'network':'xxx-deferred-xxx',
43                                           'broadcast':'xxx-deferred-xxx',
44                                           'netmask':'xxx-deferred-xxx',
45                                           'dns1': 'xxx-deferred-xxx',
46                                           'dns2': 'xxx-deferred-xxx',
47                                           },
48              ######## how to deal with the new plcapi way of modeling interfaces
49              # this pertains to the node as per the new interface - using UpdateNode
50              # after node_fields above is used to create the Node
51              'node_fields_nint' :       { 'dns':'xxx-deferred-xxx',
52                                           },
53              # used in replacement of interface_fields above
54              'interface_fields_nint' :  { 'is_primary' : True,
55                                           'method' : 'static',
56                                           },
57              # used to create an IpAddress
58              'ipaddress_fields' :       { 'type' : 'ipv4',
59                                           'ip_addr' : 'xxx-deferred-xxx',
60                                           'netmask' : 'xxx-deferred-xxx',
61                                           } ,
62              # used to create a Route
63              'route_fields' :           { 'subnet' : '0.0.0.0/0',
64                                           'next_hop' : 'xxx-deferred-xxx',
65                                           },
66              }]
67
68 def all_nodenames (options,index):
69     return [ node['name'] for node in nodes(options,index)]
70
71 def users (options) :
72     return [ 
73         {'name':'admin', 'key_names' : [ 'key_admin' ],
74          'user_fields' : {'first_name':'Admin',
75                           'last_name':'Admin',
76                           'enabled':'true',
77                           'email':'admin@%s'%domain,
78                           'password':'testuseradmin'},
79          'roles':['admin']},
80
81         {'name' : 'pi', 'key_names' : [ 'key_pi' ],
82          'user_fields' : {'first_name':'PI', 'last_name':'PI',
83                           'enabled':'True',
84                           'email':'fake-pi1@%s'%domain,
85                           'password':'testpi'},
86          'roles':['pi']},
87
88         {'name':'pitech', 'key_names' : [ 'key_pi' ],
89          'user_fields' : {'first_name':'PiTech',
90                           'last_name':'PiTech',
91                           'enabled':'true',
92                           'email':'fake-pi2@%s'%domain,
93                           'password':'testusertech'},
94          'roles':['pi','tech']},
95
96         {'name' : 'tech', 'key_names' : [ 'key_user' ],
97          'user_fields' : {'first_name':'Tech', 'last_name':'Tech',
98                           'enabled':'true',
99                           'email':'fake-tech1@%s'%domain,
100                           'password':'testtech'},
101          'roles':['tech']},
102
103         {'name':'user', 'key_names' : [ 'key_user' ],
104          'user_fields' : {'first_name':'User', 'last_name':'User',
105                           'enabled':'true',
106                           'email':'fake-user1@%s'%domain,
107                           'password':'testuser'},
108          'roles':['user']},
109
110         {'name':'techuser', 'key_names' : [ 'key_user' ],
111          'user_fields' : {'first_name':'UserTech', 'last_name':'UserTech',
112                           'enabled':'true',
113                           'email':'fake-tech2@%s'%domain,
114                           'password':'testusertech'},
115          'roles':['tech','user']},
116
117         ]
118
119 def all_usernames (options):
120     return [ user['name'] for user in users(options)]
121
122 def sites (options,index):
123     latitude= -90 + (index*10)
124     longitude= -180 + (index*20)
125     return [ {'site_fields' : {'name':'main site for plc number %d'%index,
126                                'login_base':login_base(index),
127                                'abbreviated_name':'PlanetTest%d'%index,
128                                'max_slices':100,
129                                'url':'http://test.%s'%domain,
130                                'latitude':float(latitude),
131                                'longitude':float(longitude),
132                                },
133               'address_fields' : {'line1':'route des lucioles',
134                                   'city':'sophia',
135                                   'state':'fr',
136                                   'postalcode':'06600',
137                                   'country':'France',
138                                   },
139               'users' : users(options),
140               'nodes': nodes(options,index),
141             }]
142
143 ##########
144 # key0 -> planetlab admin
145 # key1 -> planetlab PI
146 # key2 -> planetlab user
147 # key3 -> sfa PI
148 # key4 -> sfa user
149 public_key0="""ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3okOugCBs2j/uur/lBdNUqWG0VdLdrELy85MR6mGOER5ijdbZekEG6KD4zzG2fwXOzdGF99HTQAOXvty02V5/sBN/GbT1Rehwh3cUvZ8i3aJIdN4ku+zbWK6CBsQ8XGXMpCImALDxcvcaoToWJbephDpkgKtcBwmowmOQswO4GTzIdT217J13Z860Jz/QJPIjloS7HpuLmKVlZ/sWCYcuKmR4X7evCXrvbHh+iamSrOHV9sQ6Sf0Wu+VJRaUN92BrxVi9zuJNWZWtWWWjLecyaooOVS0UMBZKUNbnuGXSJ8IFHfQ9wpGGsG+KohvGH4Axh3utaDOlUG641iM5GVBX planetlab-admin@test.onelab.eu
150 """
151
152 private_key0="""-----BEGIN RSA PRIVATE KEY-----
153 MIIEpAIBAAKCAQEAt6JDroAgbNo/7rq/5QXTVKlhtFXS3axC8vOTEephjhEeYo3W
154 2XpBBuig+M8xtn8Fzs3RhffR00ADl77ctNlef7ATfxm09UXocId3FL2fIt2iSHTe
155 JLvs21iuggbEPFxlzKQiJgCw8XL3GqE6FiW3qYQ6ZICrXAcJqMJjkLMDuBk8yHU9
156 teydd2fOtCc/0CTyI5aEux6bi5ilZWf7FgmHLipkeF+3rwl672x4fompkqzh1fbE
157 Okn9FrvlSUWlDfdga8VYvc7iTVmVrVlloy3nMmqKDl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usRQjLy5BPsMqyZXQfKKXibWoZXMnr23yjsat
174 7VybVpxQHcq5byYqkGb5U8it6xUJUsiqSAPtn0NcYwGENg4xDH4r3GsiwbgVpLmS
175 4FPXjOMCgYA40bzt7QjKBURj3A9nMrFpbg1dQjNZv7ThnDq2KcLlQxusddSO3Tou
176 capLbON5tuaHbiGGVYSiUCHC6HXYWN7JGytpAjAYZhLWmK7ltNMlDQA9FX8LktPE
177 UToHxiKAuREDgRP9waHmk16833hNe8tDvX5P9vKWxx1AtZRuJoFozw==
178 -----END RSA PRIVATE KEY-----
179 """
180
181 public_key1="""ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4jNj8yT9ieEc6nSJz/ESu4fui9WrJ2y/MCfqIZ5WcdVKhBFUYyIenmUaeTduMcSqvoYRQ4QnFR1BFdLG8XR9D6FWZ5zTKUgpkew22EVNeqai4IXeWYKyt1Qf3ehaz9E3o1PG/bmQNIM6aQay6TD1Y4lqXI+eTVXVQev4K2fixySjFQpp9RB4UHbeA8c28yoa/cgAYHqCqlvm9uvpGMjgm/Qa4M+ZeO7NdjowfaF/wF4BQIzVFN9YRhvQ/d8WDz84B5Pr0J7pWpaX7EyC4bvdskxl6kmdNIwIRcIe4OcuIiX5Z9oO+7h/chsEVJWF4vqNIYlL9Zvyhnr0hLLhhuk2bw== planetlab-pi@test.onelab.eu
182 """
183 private_key1="""-----BEGIN RSA PRIVATE KEY-----
184 MIIEogIBAAKCAQEA4jNj8yT9ieEc6nSJz/ESu4fui9WrJ2y/MCfqIZ5WcdVKhBFU
185 YyIenmUaeTduMcSqvoYRQ4QnFR1BFdLG8XR9D6FWZ5zTKUgpkew22EVNeqai4IXe
186 WYKyt1Qf3ehaz9E3o1PG/bmQNIM6aQay6TD1Y4lqXI+eTVXVQev4K2fixySjFQpp
187 9RB4UHbeA8c28yoa/cgAYHqCqlvm9uvpGMjgm/Qa4M+ZeO7NdjowfaF/wF4BQIzV
188 FN9YRhvQ/d8WDz84B5Pr0J7pWp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lXGGPhy2WUX2DcC1AfCOrC9Qego7YxcVsvizQW/vIWLDaDXSyXp6V
205 ilQKrmejDO2Tvmdzpguv4Rs83fdyGcdUMEENQas4kCwhd49aTlEnHRbQYdV2XSY0
206 vKECgYEAlhYzfSswIF2h5/hGDLETxgNJ2kD0HIZYh7aud6X6aEYNdJopbfbEhifU
207 vTbf8GtvERDoxWEsk9Qp7km8xXfKWdcZtqIwsSmn/ri5d7iyvpIk591YIHSY0dr2
208 BO+VyPNWF+kDNI8mSUwi7jLW6liMdhNOmDaSX0+0X8CHtK898xM=
209 -----END RSA PRIVATE KEY-----
210 """
211
212 ### another keypair for the SFA user
213 public_key2="""ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQLvh5LkrjyLIr9UJznTJHMnqjdqzRdc9ekVmI9bx/5X4flnGtPBsr6bK/CPXmWjS2Vw0QOxi1NM45qkQJZXxroS0aehCCrvJRHgp/LOZykWCyNKqVopq9w0kH4jw1KFGIuwWROpOcMq2d/kAwyr6RV/W66KNVqu2XDiNOPJLcuZCuKrH++q3fPyP2zHSJ/irew7vwqIXbDSnVvvyRXYgc9KlR57L4BWthXcUofHlje8wKq7nWBQIUslYtJDryJg5tBvJIFfCFGmWZy0WJlGJd+yppI5jRvt9c6n9HyJKN22lUBTaTaDFvo+Xu5GEazLKG/v8h/o5WpxrrE6Y3TKeX planetlab-user@test.onelab.eu
214 """
215
216 private_key2="""
217 -----BEGIN RSA PRIVATE KEY-----
218 MIIEpAIBAAKCAQEA0C74eS5K48iyK/VCc50yRzJ6o3as0XXPXpFZiPW8f+V+H5Zx
219 rTwbK+myvwj15lo0tlcNEDsYtTTOOapECWV8a6EtGnoQgq7yUR4KfyzmcpFgsjSq
220 laKavcNJB+I8NShRiLsFkTqTnDKtnf5AMMq+kVf1uuijVartlw4jTjyS3LmQriqx
221 /vqt3z8j9sx0if4q3sO78KiF2w0p1b78kV2IHPSpUeey+AVrYV3FKHx5Y3vMCqu5
222 1gUCFLJWLSQ68i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HRGX9GYhiGAbvFA0hfPb038LkPffW3CQDufFStZ40ycSAyua/Tm1Q2wI428K
239 ezY12IwEr3dTbX3v25iI5nCWVyDC3Ve42jStzjmHwL+G54zGpl6/q9THcrT+37im
240 26QiuQKBgQCTUDGKLqQ+QM8dAl6IZpz+oExdDCWwCNjTMH83tz1Rwoc+npW7z2ZC
241 D/FseVOmS9MqJkgCap5pr4m1Qj5YciZNteIHdkIbD1yDoPaW1NvlOnxzVBQXK3HD
242 rUck4dxa0t30wUFK0XVQjNEArXqvU23EB8Z7bQQMRx0yhd4pF5k29Q==
243 -----END RSA PRIVATE KEY-----
244 """
245
246 ### for a PI
247 public_key3="""ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA9LrXvUvGZK092R+0+xNZAOUrywDmfdtOL2XqtO26PCjns2GmxLmphJkvBBtXCt4d8s9jdPILHKnTC0/8/WfrwhZ68AWHay1qnCnWjgMUFEg2J4+MsT0UpirQ7wQbA3KeuAVobRaMIdfgPwlgnmBu2VyPiS4eD4KDz2CgL2DIWzq+DzrakOSqS6eb5MMNS7rIDlxH0WV9bTueweoeWi77zpEtA4sA4EFRKZ21uNyceQ/ob8mKC1yAz2XGIKoLgaxRvd+d8Mmq52OLzbCPtDCnCAtWW2PJt8hEjR+RKwYhf0NcpMXhA5GsYAXUFmHUI0j0f/8qodWuIorE/5zr4EVVkQ== sfa-pi@test.onelab.eu
248 """
249
250 private_key3="""
251 -----BEGIN RSA PRIVATE KEY-----
252 MIIEoQIBAAKCAQEA9LrXvUvGZK092R+0+xNZAOUrywDmfdtOL2XqtO26PCjns2Gm
253 xLmphJkvBBtXCt4d8s9jdPILHKnTC0/8/WfrwhZ68AWHay1qnCnWjgMUFEg2J4+M
254 sT0UpirQ7wQbA3KeuAVobRaMIdfgPwlgnmBu2VyPiS4eD4KDz2CgL2DIWzq+Dzra
255 kOSqS6eb5MMNS7rIDlxH0WV9bTueweoeWi77zpEtA4sA4EFRKZ21uNyceQ/ob8mK
256 C1yA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QfzAAZLU2BabjwIfmWetj55ZKiFXRQLkYkz1GPXr2m3FopZb+6apq9M7tTERq1J9
273 ORxipg3+uy/eYngUAmNmzOnK/9zklEPjNm9Nw3xHnZO+SyQLNI421KkdHOja/GGd
274 awKBgQCLtk0+RpswH451PWyAJ6F+U4YDVaHR0s6pwp4TJAkDVlFBiRO28jEb5y0N
275 bI1R7vrRdq07SgI3USLXqDokQ/pXJhC03w2r7W7niAkNaUll3YtJ2DZVSvuQguR9
276 xwRNsuo0x60e7bivU+kNZtLn5FqWuGoBONZnbhgP6y7jPsNrig==
277 -----END RSA PRIVATE KEY-----
278 """
279
280 public_key4="""ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIim+K+tfwI7KcfbtX/FB1DQCWU1RY8eH4b18KywxI3DDuHa4jGvPjeU5WPwfOsUFpWcWMXCmA26TSOmeT2HiiSJNLUKB0keu/PtHAGnn6rFv5YjCF2fa65wZVkEy6eb8buBny+2L5jhFPW0KE4JNTCiueAEbWZInTWmdA1WB8QeTV3USi33NTtYE05I2/x4G2BtFmmzWzCuyRVjkWZQPJY6wIyM1+qGixpbacScxYYDBGA0I9N9VSN9OS2BN3GY8xFJjFSD2+GxsUhDUmUw2bO8ppn2OSl8NUW/U4EQzUTP8VhebI6UqjfIGAv5qHPpe0Yrcrd/QlbWvj2zpqvVtX sfa-user@test.onelab.eu
281 """
282
283 private_key4="""
284 -----BEGIN RSA PRIVATE KEY-----
285 MIIEpQIBAAKCAQEAyIpvivrX8COynH27V/xQdQ0AllNUWPHh+G9fCssMSNww7h2u
286 Ixrz43lOVj8HzrFBaVnFjFwpgNuk0jpnk9h4okiTS1CgdJHrvz7RwBp5+qxb+WIw
287 hdn2uucGVZBMunm/G7gZ8vti+Y4RT1tChOCTUworngBG1mSJ01pnQNVgfEHk1d1E
288 ot9zU7WBNOSNv8eBtgbRZps1swrskVY5FmUDyWOsCMjNfqhosaW2nEnMWGAwRgNC
289 PTfVUjfTktgTdxmPMRSYxUg9vh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zYol9NmxlxdG0FGrngbZAO/vrqLe93gmi9skvp
306 gjzQaDSKdpm3j4uz4AfW7WSJ0azCbxxXDiiBYM5jCvIFt8yTXypvqi9XWb9XqfIl
307 DVI0vsevAoGAb0SgdcyRcIrozl7Rky1GUTcCPXGMCCts9kMWNucWq6jvkCo8YdH1
308 b+fHzZFpKJNbpROjJ1er3U5jg6qtA32mbuQ9IhoYqtLISJqV+MO36pDFmjPng0+D
309 NhwboXV6u+hSpUHGK+MmqGgKkkZI6KRwTT+NWZY2FTX3UOl8IMymTBk=
310 -----END RSA PRIVATE KEY-----
311 """
312
313 master_key_index = {
314     'key_admin':    {'private':private_key0, 'public':public_key0},
315     'key_pi':       {'private':private_key1, 'public':public_key1},
316     'key_user':     {'private':private_key2, 'public':public_key2},
317     'key_sfapi':    {'private':private_key3, 'public':public_key3},
318     'key_sfauser':  {'private':private_key4, 'public':public_key4},
319 }
320
321 plc_key_names = [ 'key_admin', 'key_pi', 'key_tech' ]
322
323 # expose a list of key_specs
324 #  { 'key_name':<>, 'private':<>, 'public':<>, 'in_plc':<bool>, key_fields: <for AddKey>, }
325 def keys (options,index):
326     result = []
327     for (key_name, priv_pub) in master_key_index.items():
328         private=priv_pub['private']
329         public=priv_pub['public']
330         result.append( { 'key_name': key_name,
331                          'private':private,
332                          'public':public,
333                          'in_plc': key_name in plc_key_names,
334                          'key_fields' : {'key_type':'ssh',
335                                          'key': public},
336                          } )
337     return result
338
339 ############################## initscripts
340 initscript_by_name="""#!/bin/bash
341 command=$1; shift
342 slicename=$1; shift
343 stamp="the_script_name"
344 stampfile=/tmp/$stamp.stamp
345
346 echo "Running initscript with command=$command and slicename=$slicename"
347
348 function start () {
349   (echo Starting test initscript: $stamp on slicename $slicename ; date) >> $stampfile
350   echo "This is the stdout of the sliver $slicename initscript $command (exp. start) pid=$$" 
351   echo "This is the stderr of the sliver $slicename initscript $command (exp. start) pid=$$" 1>&2
352 }
353 function stop () {
354   echo "Removing stamp $stampfile"
355   rm -f $stampfile
356 }
357 function restart () {
358   stop
359   start
360 }
361 case $command in 
362 start) start ;;
363 stop) stop ;;
364 restart) restart ;;
365 *) echo "Unknown command in initscript $command" ;;
366 esac
367 """
368
369 initscript_by_code=initscript_by_name.replace("the_script_name","the_script_code")
370
371 # one single initscript in the InitScripts table
372 def initscripts(options,index): 
373     return [ { 'initscript_fields' : { 'enabled' : True,
374                                        'name':'the_script_name',
375                                        'script' : initscript_by_name,
376                                        }},
377              ]
378
379 # returns 3 slices
380 # 1 has an initscript code
381 # 2 has an initscript name
382 # 3 is an omf-friendly slice
383 def slices (options,index):
384     def theslice (i):
385         slice_spec = { 'slice_fields': {'name':'%s_sl%d'%(login_base(index),i),
386                                         'instantiation':'plc-instantiated',
387                                         'url':'http://foo%d.com'%index,
388                                         'description':'testslice number %d'%i,
389                                         'max_nodes':2,
390                                         },
391                        'usernames' : [ 'pi','user','techuser' ],
392                        'nodenames' : all_nodenames(options,index),
393                        'sitename' : login_base(index),
394                        'owner' : 'pi',
395                        }
396         # 1st one has an initscript_code
397         if i%3==1:
398             slice_spec['initscriptcode']=initscript_by_code
399             slice_spec['initscriptstamp']='the_script_code'
400         # 2nd one has an initscript (name)
401         elif i%3==2:
402             slice_spec['initscriptname']='the_script_name'
403             slice_spec['initscriptstamp']='the_script_name'
404         # 3rd one is omf-friendly
405         else:
406             slice_spec ['omf-friendly'] = True
407         return slice_spec
408     # usual index is 1, additional plc's then get 2...
409     # so index=1 -> 1 - 2 - 3
410     #    index=2 -> 4 - 5 - 6
411     # 3 * (index-1) + 1 = 3*index-2  .. same+3 = 3*index+1
412 #    return [ theslice(i) for i in range (3*index-2,3*index+1) ]
413 # avoid the third one for when omf is not available
414     return [ theslice(i) for i in range (3*index-2,3*index) ]
415
416 def all_slicenames (options,index):
417     return [ slice['slice_fields']['name'] for slice in slices(options,index)]
418
419 # the logic here is to try:
420 # . client and server on the same slice/node
421 # . client and server on the same node but 2 different slices
422 # if at least 2 plcs, we have 2 nodes, so again on diff. nodes
423 def tcp_specs (options,index):
424     # only run the test on the first plc
425     if index != 1: return None
426     # 
427     slice1='%s_sl1'%login_base(1)
428     slice2='%s_sl2'%login_base(1)
429     # with the addition of omf-friendly slices..
430     slice3='%s_sl4'%login_base(2)
431     slice4='%s_sl5'%login_base(2)
432 # bind on 0.0.0.0 and try to reach this on localhost
433 # not expected to work
434     same_node_same_slice_lo =   { 'server_node': 'node1', 'server_slice': slice1,
435                                   'client_node': 'node1', 'client_slice': slice1,
436                                   'client_connect' : 'localhost',
437                                   'port': 10000}
438     same_node_same_slice =      { 'server_node': 'node1', 'server_slice': slice1,
439                                   'client_node': 'node1', 'client_slice': slice1,
440                                   'port': 10001}
441 # this does not work on vs-nodes....
442     same_node_2_slices =        { 'server_node': 'node1', 'server_slice': slice1,
443                                   'client_node': 'node1', 'client_slice': slice2,
444                                   'port': 10002}
445     two_nodes_same_slice =      { 'server_node': 'node1', 'server_slice': slice1,
446                                   'client_node': 'node2', 'client_slice': slice3,
447                                   'port': 10003}
448     two_nodes_2_slices =        { 'server_node': 'node1', 'server_slice': slice1,
449                                   'client_node': 'node2', 'client_slice': slice4,
450                                   'port': 10004}
451     specs = []
452 #    specs += [ same_node_same_slice_lo ]
453     specs += [ same_node_same_slice ]
454 # worth another try
455     specs += [ same_node_2_slices ]
456     if options.size >1 :
457         specs += [ two_nodes_same_slice, two_nodes_2_slices ]
458     return specs
459
460 # the semantic for 't_from' and 't_until' here is:
461 # if they are smaller than one year, they are relative to the current time, expressed in grains
462 # otherwise they are absolute
463 def leases (options, index):
464     leases=[]
465     counter=0
466     slices=all_slicenames(options,index)
467     slice_sequence = slices[:1] + slices + [None,]
468     for iterator in range(12):
469         for slice in slice_sequence:
470             leases.append ( {'slice' : slice, 't_from':counter,'t_until':counter+1} )
471             counter += 1
472     return leases
473
474 def plc (options,index) :
475     return { 
476         'index' : index,
477         'name' : 'plctest%d'%index,
478         # as of yet, not sure we can handle foreign hosts, but this is required though
479         'host_box' : 'deferred-myplc-hostbox-%d'%index,
480         # set these two items to run within a vserver
481         'vservername': 'deferred-vservername',
482         'vserverip': 'deferred-vserverip',
483         'role' : 'root',
484         'PLC_NAME' : 'Regression TestLab',
485         'PLC_ROOT_USER' : 'root@test.onelab.eu',
486         'PLC_ROOT_PASSWORD' : 'test++',
487         'PLC_SLICE_PREFIX' : 'auto',
488         'PLC_HRN_ROOT': sfa_root(index),
489         'PLC_SHORTNAME' : 'Rlab',
490         'PLC_MAIL_ENABLED':'false',
491         'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@inria.fr',
492         'PLC_DB_HOST' : 'deferred-myplc-hostname',
493 #        'PLC_DB_PASSWORD' : 'mnbvcxzlkjhgfdsapoiuytrewq',
494         'PLC_API_HOST' : 'deferred-myplc-hostname',
495         'PLC_WWW_HOST' : 'deferred-myplc-hostname',
496         'PLC_BOOT_HOST' : 'deferred-myplc-hostname',
497         'PLC_NET_DNS1' : 'deferred-dns-1',
498         'PLC_NET_DNS2' : 'deferred-dns-2',
499         'PLC_RESERVATION_GRANULARITY':1800,
500         'PLC_VSYS_DEFAULTS':' , vif_up, vif_down, fd_tuntap, promisc, ',
501         'expected_vsys_tags': [ 'vif_up', 'vif_down', 'fd_tuntap', 'promisc', ],
502         # minimal config so the omf plugins actually trigger
503         'PLC_OMF_ENABLED' : 'true',
504         'PLC_OMF_XMPP_SERVER': 'deferred-myplc-hostname',
505         'sites' : sites(options,index),
506         'keys' : keys(options,index),
507         'initscripts': initscripts(options,index),
508         'slices' : slices(options,index),
509         'tcp_specs' : tcp_specs(options,index),
510         'sfa' : sfa(options,index),
511         'leases' : leases (options, index),
512         # big distros need more time to install nodes
513         'ssh_node_boot_timers': (40,38),
514         'ssh_node_debug_timers': (10,8),
515     }
516
517 # NOTE: SFA currently has SFA_AGGREGATE_API_VERSION=2 baked into the code
518 def sfa (options,index) :
519     return { 
520         # the default is to use AMs in the various aggregates.xml
521         # stack config_sfamesh to point to SMs instead
522         'neighbours-port':12346,
523         ## global sfa-config-tty stuff
524         'SFA_REGISTRY_ROOT_AUTH' : sfa_root(index),
525         'SFA_INTERFACE_HRN' : sfa_root(index),
526         'SFA_REGISTRY_HOST' : 'deferred-myplc-hostname',
527         'SFA_AGGREGATE_HOST': 'deferred-myplc-hostname',
528         'SFA_SM_HOST': 'deferred-myplc-hostname',
529         'SFA_PLC_URL' : 'deferred-myplc-api-url',
530         'SFA_PLC_USER' : 'root@test.onelab.eu',
531         'SFA_PLC_PASSWORD' : 'test++',
532 # use -c sfadebug to increment this one
533         'SFA_API_LOGLEVEL': 1,
534 # use -c sfavoid to set this to 'void'
535         'SFA_GENERIC_FLAVOUR' : 'pl',
536         'SFA_AGGREGATE_ENABLED' : 'true',
537         # details of the slices to create
538         'auth_sfa_specs' : [ test_auth_sfa_spec(options,index,rspec_style) 
539                              for rspec_style in options.rspec_styles ]
540     }
541
542 # rspecstyle is 'pl' for sfav1 or 'pg' for pgv2
543 def test_auth_sfa_spec (options,index,rspec_style):
544     # the auth/site part per se
545     login_base=sfa_login_base(index,rspec_style)
546     hrn_prefix='%s.%s'%(sfa_root(index),login_base)
547     def full_hrn(x):  return "%s.%s"%(hrn_prefix,x)
548     def full_mail(x): return "%s@test.%s"%(x,domain)
549
550     # 2 users
551     pi_spec = {
552         'name':         'pi',
553         'email':        full_mail ('piuser'),
554         'key_name':     'key_sfapi',
555         }
556     user_hrn = full_hrn ('us')
557     user_spec = {
558         'name':         'us',
559         'email':        full_mail ('regularuser'),
560         'key_name':     'key_sfauser',
561         'add_options':  [ '--extra',"first_name=Fake",
562                           '--extra',"last_name=SFA-style-%s"%rspec_style,
563                           ],
564         'update_options': [ '--extra',"enabled=true",
565                              ],
566         }
567
568     slice_spec = {
569         'name':          'sl',
570         'add_options':  [ '--researchers', user_hrn,
571                           # xxx
572                           '--extra', "description=SFA-testing-%s"%rspec_style,
573                           '--extra', "url=http://slice%d.test.onelab.eu/"%index,
574                           '--extra', "max_nodes=2",
575                           ],
576         'key_name':    'key_sfauser',
577         'nodenames':    all_nodenames(options,index),
578         }
579         
580     # we're already in a dedicated site/authority so no need to encumber with odd names
581
582     return { #'hrn_prefix': hrn_prefix,
583              'login_base' : login_base,
584              'domain':domain,
585              'rspec_style':rspec_style,
586              'pi_spec': pi_spec,
587              'user_spec': user_spec,
588              'slice_spec': slice_spec,
589              } 
590
591
592 def config (plc_specs,options):
593     result=plc_specs
594     # plc 'index' starts with 1 
595     for i in range (options.size):
596         result.append(plc(options,i+1))
597     return result