Merge branch 'master' of ssh://git.onelab.eu/git/tests
[tests.git] / system / config_default.py
index 39d5e41..16a4e90 100644 (file)
@@ -92,11 +92,15 @@ def all_usernames (options):
     return [ user['name'] for user in users(options)]
 
 def sites (options,index):
+    latitude= -90 + (index*10)
+    longitude= -180 + (index*20)
     return [ {'site_fields' : {'name':'main site for plc number %d'%index,
                                'login_base':login_base(index),
                                'abbreviated_name':'PlanetTest%d'%index,
                                'max_slices':100,
                                'url':'http://test.onelab.eu',
+                               'latitude':float(latitude),
+                               'longitude':float(longitude),
                                },
               'address_fields' : {'line1':'route des lucioles',
                                   'city':'sophia',
@@ -149,30 +153,36 @@ def keys (options,index):
 
 
 ############################## initscripts
-initscript_by_name="""#! /bin/sh
-builtin="the_script_name"
-stamp=/tmp/$builtin.stamp
+initscript_by_name="""#!/bin/bash
 command=$1; shift
 slicename=$1; shift
-case $command in 
-start)
-  (echo Starting test initscript: $builtin on slicename $slicename ; date) >> $stamp
+stamp="the_script_name"
+stampfile=/tmp/$stamp.stamp
+
+echo "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
-;;
-stop)
-  rm $stamp
-;;
-restart)
-  echo "Dummy restart"
-;;
-*)
-  echo "Unknown command in initscript $command"
-;;
+}
+function stop () {
+  echo "Removing stamp $stampfile"
+  rm -f $stampfile
+}
+function restart () {
+  stop
+  start
+}
+case $command in 
+start) start ;;
+stop) stop ;;
+restart) restart ;;
+*) echo "Unknown command in initscript $command" ;;
 esac
 """
 
-initscript_by_body=initscript_by_name.replace("the_script_name","the_script_body")
+initscript_by_code=initscript_by_name.replace("the_script_name","the_script_code")
 
 # one single initscript in the InitScripts table
 def initscripts(options,index): 
@@ -183,7 +193,7 @@ def initscripts(options,index):
              ]
 
 # always return 2 slices
-# one has an initscript body, the other one an initscript name
+# one has an initscript code, the other one an initscript name
 def slices (options,index):
     def theslice (i):
         slice_spec = { 'slice_fields': {'name':'%s_pslc%d'%(login_base(index),i),
@@ -192,19 +202,21 @@ def slices (options,index):
                                         'description':'testslice number %d'%i,
                                         'max_nodes':2,
                                         },
-                       'usernames' : [ 'pi','tech','techuser' ],
+                       'usernames' : [ 'pi','user','techuser' ],
                        'nodenames' : all_nodenames(options,index),
                        'sitename' : login_base(index),
                        'owner' : 'pi',
                        }
-        # odd one has an initscript_body
+        # odd one has an initscript_code
         if i%2==1:
-            slice_spec['initscriptbody']=initscript_by_body
-            slice_spec['initscriptstamp']='the_script_body'
+            slice_spec['initscriptcode']=initscript_by_code
+            slice_spec['initscriptstamp']='the_script_code'
+        # even one has an initscript (name)
         else:
             slice_spec['initscriptname']='the_script_name'
             slice_spec['initscriptstamp']='the_script_name'
-    return [ theslice(1) for i in range (2*index-1,2*index+1) ]
+        return slice_spec
+    return [ theslice(i) 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)]
@@ -248,6 +260,7 @@ def leases (options, index):
 
 def plc (options,index) :
     return { 
+        'index' : index,
         'name' : 'onetest%d'%index,
         # as of yet, not sure we can handle foreign hosts, but this is required though
         'hostname' : 'deferred-myplc-hostbox-%d'%index,
@@ -309,6 +322,9 @@ def sfa (options,index) :
         'regularuser':regularuser,
         'slicename' : slicename,
         'domain':domain,
+        # the default is to use AMs in the various aggregates.xml
+        # stack config_sfamesh to point to SMs instead
+        'neighbours-port':12346,
     }
 
 def sfa_slice_specs (options,index,slicename,regularuser):