keep track of what has moved to py3
[tests.git] / system / config_default.py
index 9bd90d4..8fd549a 100644 (file)
@@ -1,5 +1,6 @@
+# -*- python3 -*-
 # Thierry Parmentelat <thierry.parmentelat@inria.fr>
-# Copyright (C) 2010 INRIA 
+# Copyright (C) 2015 INRIA 
 #
 # a configuration module is expected:
 # (*) to define a config method
@@ -10,7 +11,9 @@
 
 # values like 'hostname', 'ip' and the like are rewritten later with a TestPool object
 
-domain="onelab.eu"
+# so that sfa users get different mails whether they are based on pl or pg
+pldomain="onelab.eu"
+pgdomain="emulab.eu"
 
 ### for the sfa dual setup
 def login_base (index): 
@@ -63,6 +66,9 @@ def nodes(options,index):
              'route_fields' :           { 'subnet' : '0.0.0.0/0',
                                           'next_hop' : 'xxx-deferred-xxx',
                                           },
+             # boot cd settings
+             # we should have tags here instead of the hard-wired
+             # options set for GetBootMedium in TestNode.py
              }]
 
 def all_nodenames (options,index):
@@ -74,14 +80,14 @@ def users (options) :
          'user_fields' : {'first_name':'Admin',
                           'last_name':'Admin',
                           'enabled':'true',
-                          'email':'admin@%s'%domain,
+                          'email':'admin@%s'%pldomain,
                           'password':'testuseradmin'},
          'roles':['admin']},
 
         {'name' : 'pi', 'key_names' : [ 'key_pi' ],
          'user_fields' : {'first_name':'PI', 'last_name':'PI',
                           'enabled':'True',
-                          'email':'fake-pi1@%s'%domain,
+                          'email':'fake-pi1@%s'%pldomain,
                           'password':'testpi'},
          'roles':['pi']},
 
@@ -89,28 +95,28 @@ def users (options) :
          'user_fields' : {'first_name':'PiTech',
                           'last_name':'PiTech',
                           'enabled':'true',
-                          'email':'fake-pi2@%s'%domain,
+                          'email':'fake-pi2@%s'%pldomain,
                           'password':'testusertech'},
          'roles':['pi','tech']},
 
         {'name' : 'tech', 'key_names' : [ 'key_user' ],
          'user_fields' : {'first_name':'Tech', 'last_name':'Tech',
                           'enabled':'true',
-                          'email':'fake-tech1@%s'%domain,
+                          'email':'fake-tech1@%s'%pldomain,
                           'password':'testtech'},
          'roles':['tech']},
 
         {'name':'user', 'key_names' : [ 'key_user' ],
          'user_fields' : {'first_name':'User', 'last_name':'User',
                           'enabled':'true',
-                          'email':'fake-user1@%s'%domain,
+                          'email':'fake-user1@%s'%pldomain,
                           'password':'testuser'},
          'roles':['user']},
 
         {'name':'techuser', 'key_names' : [ 'key_user' ],
          'user_fields' : {'first_name':'UserTech', 'last_name':'UserTech',
                           'enabled':'true',
-                          'email':'fake-tech2@%s'%domain,
+                          'email':'fake-tech2@%s'%pldomain,
                           'password':'testusertech'},
          'roles':['tech','user']},
 
@@ -126,7 +132,7 @@ def sites (options,index):
                                'login_base':login_base(index),
                                'abbreviated_name':'PlanetTest%d'%index,
                                'max_slices':100,
-                               'url':'http://test.%s'%domain,
+                               'url':'http://test.%s'%pldomain,
                                'latitude':float(latitude),
                                'longitude':float(longitude),
                                },
@@ -340,18 +346,19 @@ def keys (options,index):
 initscript_by_name="""#!/bin/bash
 command=$1; shift
 slicename=$1; shift
-stamp="the_script_name"
-stampfile=/tmp/$stamp.stamp
+stamp="initscript_by_name"
+stampfile=/var/tmp/$stamp.stamp
+date=$(date)
 
-echo "Running initscript with command=$command and slicename=$slicename"
+echo $date "Running initscript with command=$command and slicename=$slicename"
 
 function start () {
-  (echo Starting test initscript: $stamp on slicename $slicename ; date) >> $stampfile
-  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
+  (echo $date Starting test initscript: $stamp on slicename $slicename ; date) >> $stampfile
+  echo $date "This is the stdout of the sliver $slicename initscript $command (exp. start) pid=$$"
+  echo $date "This is the stderr of the sliver $slicename initscript $command (exp. start) pid=$$" 1>&2
 }
 function stop () {
-  echo "Removing stamp $stampfile"
+  echo $date "Removing stamp $stampfile"
   rm -f $stampfile
 }
 function restart () {
@@ -366,12 +373,12 @@ restart) restart ;;
 esac
 """
 
-initscript_by_code=initscript_by_name.replace("the_script_name","the_script_code")
+initscript_by_code=initscript_by_name.replace("initscript_by_name","initscript_by_code")
 
 # one single initscript in the InitScripts table
 def initscripts(options,index): 
     return [ { 'initscript_fields' : { 'enabled' : True,
-                                       'name':'the_script_name',
+                                       'name':'initscript_by_name',
                                        'script' : initscript_by_name,
                                        }},
              ]
@@ -393,16 +400,17 @@ def slices (options,index):
                        'sitename' : login_base(index),
                        'owner' : 'pi',
                        }
-        # 1st one has an initscript_code
+        # 1st one has an initscript by code
         if i%3==1:
             slice_spec['initscriptcode']=initscript_by_code
-            slice_spec['initscriptstamp']='the_script_code'
-        # 2nd one has an initscript (name)
+            slice_spec['initscriptstamp']='initscript_by_code'
+        # 2nd one has an initscript by name
         elif i%3==2:
-            slice_spec['initscriptname']='the_script_name'
-            slice_spec['initscriptstamp']='the_script_name'
+            slice_spec['initscriptname']='initscript_by_name'
+            slice_spec['initscriptstamp']='initscript_by_name'
         # 3rd one is omf-friendly
         else:
+            # potentially turned off with config_no_omf
             slice_spec ['omf-friendly'] = True
         return slice_spec
     # usual index is 1, additional plc's then get 2...
@@ -427,6 +435,9 @@ def tcp_specs (options,index):
     # with the addition of omf-friendly slices..
     slice3='%s_sl4'%login_base(2)
     slice4='%s_sl5'%login_base(2)
+
+# NOTE: port 9999 is hard-wired in the code to be used for checking network readiness
+# so it is not to be used here
 # bind on 0.0.0.0 and try to reach this on localhost
 # not expected to work
     same_node_same_slice_lo =   { 'server_node': 'node1', 'server_slice': slice1,
@@ -451,7 +462,7 @@ def tcp_specs (options,index):
     specs += [ same_node_same_slice ]
 # worth another try
     specs += [ same_node_2_slices ]
-    if options.size >:
+    if options.size > 1:
         specs += [ two_nodes_same_slice, two_nodes_2_slices ]
     return specs
 
@@ -479,83 +490,98 @@ def plc (options,index) :
         'vservername': 'deferred-vservername',
         'vserverip': 'deferred-vserverip',
         'role' : 'root',
-        'PLC_NAME' : 'Regression TestLab',
-        'PLC_ROOT_USER' : 'root@test.onelab.eu',
-        'PLC_ROOT_PASSWORD' : 'test++',
-        'PLC_SLICE_PREFIX' : 'auto',
-        'PLC_SHORTNAME' : 'Rlab',
-        'PLC_MAIL_ENABLED':'false',
-        'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@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':1800,
-        'PLC_VSYS_DEFAULTS':' , vif_up, vif_down, fd_tuntap, promisc, ',
+        # these go to plc-config-tty
+        'settings': {
+            'PLC_NAME' : 'Regression TestLab',
+            'PLC_ROOT_USER' : 'root@test.onelab.eu',
+            'PLC_ROOT_PASSWORD' : 'test++',
+            'PLC_SLICE_PREFIX' : 'auto',
+            'PLC_HRN_ROOT': sfa_root(index),
+            'PLC_SHORTNAME' : 'Rlab',
+            'PLC_MAIL_ENABLED':'false',
+            'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@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':1800,
+            'PLC_VSYS_DEFAULTS':' , vif_up, vif_down, fd_tuntap, promisc, ',
+            'PLC_OMF_ENABLED' : 'true',
+            'PLC_OMF_XMPP_SERVER': 'deferred-myplc-hostname',
+        },
         'expected_vsys_tags': [ 'vif_up', 'vif_down', 'fd_tuntap', 'promisc', ],
         # minimal config so the omf plugins actually trigger
-        'PLC_OMF_ENABLED' : 'true',
-        'PLC_OMF_XMPP_SERVER': 'deferred-myplc-hostname',
         'sites' : sites(options,index),
         'keys' : keys(options,index),
         'initscripts': initscripts(options,index),
         'slices' : slices(options,index),
         'tcp_specs' : tcp_specs(options,index),
-       'sfa' : sfa(options,index),
+        'sfa' : sfa(options,index),
         'leases' : leases (options, index),
         # big distros need more time to install nodes
         'ssh_node_boot_timers': (40,38),
         'ssh_node_debug_timers': (10,8),
     }
 
-# NOTE: SFA currently has SFA_AGGREGATE_API_VERSION=2 baked into the code
 def sfa (options,index) :
     return { 
-        # the default is to use AMs in the various aggregates.xml
+        # the port used to generate the various aggregates.xml
         # stack config_sfamesh to point to SMs instead
         'neighbours-port':12346,
+        # the port that sfi connects to - used to be 12347 when the SM was still running
+        # but now the SM is just turned off for these tests
+        'sfi-connects-to-port' : 12346,
         ## global sfa-config-tty stuff
-        'SFA_REGISTRY_ROOT_AUTH' : sfa_root(index),
-        'SFA_INTERFACE_HRN' : sfa_root(index),
-       'SFA_REGISTRY_HOST' : 'deferred-myplc-hostname',
-       'SFA_AGGREGATE_HOST': 'deferred-myplc-hostname',
-       'SFA_SM_HOST': 'deferred-myplc-hostname',
-       'SFA_PLC_URL' : 'deferred-myplc-api-url',
-        'SFA_PLC_USER' : 'root@test.onelab.eu',
-        'SFA_PLC_PASSWORD' : 'test++',
+        'settings': {
+            'SFA_REGISTRY_ROOT_AUTH' : sfa_root(index),
+            'SFA_INTERFACE_HRN' : sfa_root(index),
+            'SFA_REGISTRY_HOST' : 'deferred-myplc-hostname',
+            'SFA_AGGREGATE_HOST': 'deferred-myplc-hostname',
+            'SFA_SM_HOST': 'deferred-myplc-hostname',
+# turning off SM and using only AM; be explicit on this as the default has changed in the code
+            'SFA_SM_ENABLED' : 'false',
+            'SFA_PLC_URL' : 'deferred-myplc-api-url',
+            'SFA_PLC_USER' : 'root@test.onelab.eu',
+            'SFA_PLC_PASSWORD' : 'test++',
 # use -c sfadebug to increment this one
-        'SFA_API_LOGLEVEL': 1,
+            'SFA_API_LOGLEVEL': 1,
 # use -c sfavoid to set this to 'void'
-        'SFA_GENERIC_FLAVOUR' : 'pl',
-        'SFA_AGGREGATE_ENABLED' : 'true',
+            'SFA_GENERIC_FLAVOUR' : 'pl',
+            'SFA_AGGREGATE_ENABLED' : 'true',
+        },
         # details of the slices to create
         'auth_sfa_specs' : [ test_auth_sfa_spec(options,index,rspec_style) 
                              for rspec_style in options.rspec_styles ]
     }
 
-# rspecstyle is 'pl' for sfav1 or 'pg' for pgv2
+# rspec_style is 'pl' for sfav1 or 'pg' for pgv2
 def test_auth_sfa_spec (options,index,rspec_style):
+    domain=pldomain if rspec_style=='pl' else pgdomain
     # the auth/site part per se
     login_base=sfa_login_base(index,rspec_style)
     hrn_prefix='%s.%s'%(sfa_root(index),login_base)
     def full_hrn(x):  return "%s.%s"%(hrn_prefix,x)
     def full_mail(x): return "%s@test.%s"%(x,domain)
 
-    # 2 users
+    # 2 users; we use dashes on purpose, as it might show up in email addresses
+    pi_alias = 'pi-user'
+    user_alias = 'regular-user'
+#    pi_alias = 'pi'
+#    user_alias = 'user'
+    # 
     pi_spec = {
-        'name':         'pi',
-        'email':        full_mail ('piuser'),
+        'name':         pi_alias,
+        'email':        full_mail (pi_alias),
         'key_name':     'key_sfapi',
         }
-    user_hrn = full_hrn ('us')
     user_spec = {
-        'name':         'us',
-        'email':        full_mail ('regularuser'),
+        'name':         user_alias,
+        'email':        full_mail (user_alias),
         'key_name':     'key_sfauser',
-        'add_options':  [ '--extra',"first_name=Fake",
+        'register_options':  [ '--extra',"first_name=Fake",
                           '--extra',"last_name=SFA-style-%s"%rspec_style,
                           ],
         'update_options': [ '--extra',"enabled=true",
@@ -564,7 +590,7 @@ def test_auth_sfa_spec (options,index,rspec_style):
 
     slice_spec = {
         'name':          'sl',
-        'add_options':  [ '--researchers', user_hrn,
+        'register_options':  [ '--researchers', full_hrn (user_alias),
                           # xxx
                           '--extra', "description=SFA-testing-%s"%rspec_style,
                           '--extra', "url=http://slice%d.test.onelab.eu/"%index,
@@ -586,9 +612,26 @@ def test_auth_sfa_spec (options,index,rspec_style):
              } 
 
 
-def config (plc_specs,options):
-    result=plc_specs
+def config (plc_specs, options):
+    result = plc_specs
     # plc 'index' starts with 1 
-    for i in range (options.size):
-        result.append(plc(options,i+1))
+    for i in range(options.size):
+        result.append(plc(options, i+1))
     return result
+
+### for creating a sample config interactively
+def sample_test_plc_spec ():
+    class Void: pass
+
+    options = Void()
+    options.size = 1
+    options.rspec_styles = ['pg']
+
+    return config([], options)[0]
+
+if __name__ == '__main__':
+    s = sample_test_plc_spec()
+    print('Sample plc_spec has the following keys')
+    for k in sorted(s.keys()):
+        print(k)    
+