unset OMF_ENABLED as this requires the XMPP values to be defined as well
[tests.git] / system / config_default.py
index 65451bb..c776991 100644 (file)
@@ -7,6 +7,8 @@
 
 # values like 'hostname', 'ip' and the like are rewritten later with a TestPool object
 
+reservation_granularity=180
+
 def nodes(options,index):
     return [{'name':'node%d'%index,
              'node_fields': {'hostname': 'deferred-nodename%d'%index,
@@ -62,6 +64,13 @@ def users (options) :
                                'email':'fake-pi2@%s'%domain,
                                'password':'testusertech'},
               'roles':['pi','tech']},
+             {'name':'admin', 'keynames' : [ 'key1' ],
+              'user_fields' : {'first_name':'Admin',
+                               'last_name':'Admin',
+                               'enabled':'true',
+                               'email':'admin@%s'%domain,
+                               'password':'testuseradmin'},
+              'roles':['admin']},
              ]
 
 def all_usernames (options):
@@ -72,7 +81,7 @@ def sites (options,index):
                                'login_base':'main',
                                'abbreviated_name':'PLanettest',
                                'max_slices':100,
-                               'url':'http://testbox1.onelab.eu',
+                               'url':'http://test.onelab.eu',
                                },
               'address_fields' : {'line1':'route des lucioles',
                                   'city':'sophia',
@@ -127,29 +136,48 @@ def initscripts(options,index):
     initscripts= [ { 'initscript_fields' : 
                      { 'enabled' : True,
                        'name':'script1',
-                       'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 1; date) > /tmp/script1.stamp \n ',
+                       'script' : """#! /bin/sh
+(echo Starting test initscript: script1; date) >> /tmp/script1.stamp
+# expected to be 'start'
+command=$1; shift
+# get slice name
+slicename=$1; shift
+echo "This is the stdout of the sliver $slicename initscript $command (exp. start) pid=$$" 
+echo "This is the stderr of the sliver $slicename initscript $command (exp. start) pid=$$" 1>&2
+""",
                        }},
                    { 'initscript_fields' : 
                      { 'enabled' : True,
                        'name':'script2',
-                       'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/script2.stamp \n ',
+                       'script' : """#! /bin/sh
+(echo Starting loop-forever test initscript: script2; date) >> /tmp/script2.stamp
+# expected to be 'start'
+command=$1; shift
+# get slice name
+slicename=$1; shift
+while true; do
+echo "This is the stdout of the loop-for-ever sliver initscript $slicename $command (exp. start) $$" 
+echo "This is the stderr of the loop-for-ever sliver initscript $slicename $command (exp. start) $$" 1>&2
+sleep 10
+done
+""",
                        }},
                    ]
     return initscripts
 
 def slices (options,index):
-    return [ { 'slice_fields': {'name':'main_slicetest%d'%index,
+    return [ { 'slice_fields': {'name':'main_pslc%d'%i,
                                 'instantiation':'plc-instantiated',
-                                'url':'http://foo%d@foo.com'%index,
-                                'description':'testslice number %d'%index,
+                                'url':'http://foo.com',
+                                'description':'testslice number %d'%i,
                                 'max_nodes':2,
                                 },
                'usernames' : [ 'pi','tech','techuser' ],
                'nodenames' : all_nodenames(options,index),
-               'initscriptname' : 'script%d'%index,
+               'initscriptname' : 'script%d'%i,
                'sitename' : 'main',
                'owner' : 'pi',
-               }]
+               } for i in range (2*index-1,2*index+1) ]
 
 def all_slicenames (options,index):
     return [ slice['slice_fields']['name'] for slice in slices(options,index)]
@@ -159,24 +187,38 @@ def tcp_tests (options,index):
         return [
             # local test
             { 'server_node': 'node1',
-              'server_slice' : 'main_slicetest1',
+              'server_slice' : 'main_pslc1',
               'client_node' : 'node1',
-              'client_slice' : 'main_slicetest1',
+              'client_slice' : 'main_pslc1',
               'port' : 2000,
               }]
     elif index == 2:
         return [
             # remote test
             { 'server_node': 'node1',
-              'server_slice' : 'main_slicetest1',
+              'server_slice' : 'main_pslc1',
               'client_node' : 'node2',
-              'client_slice' : 'main_slicetest2',
+              'client_slice' : 'main_pslc2',
               'port' : 4000,
               },
             ]
     else:
         return []
-             
+
+# the semantic for 't_from' and 't_until' here is:
+# if they are smaller than one year, they are relative to the current time
+# otherwise they are absolute
+def leases (options, index):
+    leases=[]
+    counter=0
+    slices=all_slicenames(options,index)
+    slice_sequence = slices[:1] + slices + [None,]
+    for iterator in range(12):
+        for slice in slice_sequence:
+            leases.append ( {'slice' : slice, 't_from':counter,'t_until':counter+reservation_granularity} )
+            counter += reservation_granularity
+    return leases
+
 def plc (options,index) :
     return { 
         'name' : 'onetest%d'%index,
@@ -190,23 +232,94 @@ def plc (options,index) :
         'PLC_ROOT_PASSWORD' : 'test++',
         'PLC_NAME' : 'Regression TestLab',
         'PLC_SHORTNAME' : 'Rlab',
-        'PLC_MAIL_ENABLED':'true',
+        'PLC_MAIL_ENABLED':'false',
         'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@sophia.inria.fr',
         'PLC_DB_HOST' : 'deferred-myplc-hostname',
+        'PLC_DB_PASSWORD' : 'mnbvcxzlkjhgfdsapoiuytrewq',
         'PLC_API_HOST' : 'deferred-myplc-hostname',
         'PLC_WWW_HOST' : 'deferred-myplc-hostname',
         'PLC_BOOT_HOST' : 'deferred-myplc-hostname',
         'PLC_NET_DNS1' : 'deferred-dns-1',
         'PLC_NET_DNS2' : 'deferred-dns-2',
+        'PLC_RESERVATION_GRANULARITY':reservation_granularity,
+        'PLC_OMF_ENABLED' : 'false',
         'sites' : sites(options,index),
         'keys' : keys(options,index),
         'initscripts': initscripts(options,index),
         'slices' : slices(options,index),
         'tcp_test' : tcp_tests(options,index),
+       'sfa' : sfa(options,index),
+        'leases' : leases (options, index),
     }
 
+def sfa (options,index) :
+    if index==1:
+       root_auth='plc'
+    else:
+       root_auth='ple'
+    return { 
+        'SFA_REGISTRY_ROOT_AUTH' : root_auth,
+        'SFA_REGISTRY_LEVEL1_AUTH' : '',
+       'SFA_REGISTRY_HOST' : 'deferred-myplc-hostname',
+       'SFA_AGGREGATE_HOST': 'deferred-myplc-hostname',
+       'SFA_SM_HOST': 'deferred-myplc-hostname',
+        'SFA_PLC_USER' : 'root@test.onelab.eu',
+        'SFA_PLC_PASSWORD' : 'test++',
+        'SFA_PLC_DB_HOST':'deferred-myplc-hostname',
+        'SFA_PLC_DB_USER' : 'pgsqluser',
+        'SFA_PLC_DB_PASSWORD' : 'mnbvcxzlkjhgfdsapoiuytrewq',
+       'SFA_PLC_URL' : 'deferred-myplc-api-url',
+        'slices_sfa' : slices_sfa(options,index),
+       'sfa_slice_xml' : sfa_slice_xml(options,index),
+       'sfa_person_xml' : sfa_person_xml(options,index),
+       'sfa_slice_rspec' : sfa_slice_rspec(options,index)
+    }
+
+def slices_sfa (options,index):
+    return [ { 'slice_fields': {'name':'main_fslc1',
+                                'url':'http://foo%d@foo.com'%index,
+                                'description':'SFA-testing',
+                                'max_nodes':2,
+                                },
+               'usernames' : [ ('sfafakeuser1','key1') ],
+               'nodenames' : all_nodenames(options,index),
+               'sitename' : 'main',
+               }]
+
+def sfa_slice_xml(options,index):
+    if index==1:
+       hrn='plc.main.fslc1'
+       researcher='plc.main.fake-pi1'
+    else:
+       hrn='ple.main.fslc1'
+       researcher='ple.main.fake-pi1'
+
+    return  ["""<record hrn="%s" type="slice" description="SFA-testing" url="http://anil.onelab.eu/"><researcher>%s</researcher></record>"""%(hrn, researcher)]
+
+def sfa_person_xml(options,index):
+    if index==1:
+        hrn='plc.main.sfafakeuser1'
+    else:
+        hrn='ple.main.sfafakeuser1'
+
+    return ["""<record email="sfafakeuser1@onelab.eu" enabled="True" first_name="Anil" hrn="%s" last_name="Kumar" name="%s" type="user"><keys>%s</keys><role_ids>20</role_ids><role_ids>10</role_ids><site_ids>1</site_ids><roles>pi</roles><roles>admin</roles><sites>plc.main</sites></record>"""%(hrn,hrn,public_key)]
+
+def sfa_slice_rspec(options,index):
+    node_name='deferred'
+    if index==1:
+       netspec_name='\"plc\"'
+    else:
+       netspec_name='\"ple\"'
+
+    return { 'part1' : """<?xml version="1.0" ?><Rspec><networks><NetSpec name=""",
+             'part2' : "%s"%netspec_name,
+            'part3' : """><nodes><NodeSpec cpu_min="" cpu_pct="" cpu_share="" disk_max="" init_params="" name=\"""",
+            'part4' : "%s"%node_name,
+             'part5' : """\" start_time="" type=""><net_if><IfSpec init_params="" ip_spoof="" max_kbyte="" max_rate="" min_rate="" name="True" type="ipv4"/></net_if></NodeSpec></nodes></NetSpec></networks></Rspec>"""
+           }
+             
 def config (plc_specs,options):
     result=plc_specs
     for i in range (options.size):
-        result += [ plc(options,i+1) ]
+        result.append(plc(options,i+1))
     return result