X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Fconfig_default.py;h=39d5e4178bc570d8dac49c179359065f22703513;hb=8562147f6fff5456f230b560cc7504850df24d1a;hp=a65eebada7db9d05ea73a5fea66d9c8278ec6ef6;hpb=10fc693e10cb435ad1e5058805c9431d0861a5b8;p=tests.git diff --git a/system/config_default.py b/system/config_default.py index a65eeba..39d5e41 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -147,52 +147,64 @@ def keys (options,index): 'key': public_key}} ] -def initscripts(options,index): - initscripts= [ { 'initscript_fields' : - { 'enabled' : True, - 'name':'script1', - '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 -(echo Starting loop-forever test initscript: script2; date) >> /tmp/script2.stamp -# expected to be 'start' + +############################## initscripts +initscript_by_name="""#! /bin/sh +builtin="the_script_name" +stamp=/tmp/$builtin.stamp 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 +case $command in +start) + (echo Starting test initscript: $builtin on slicename $slicename ; date) >> $stamp + 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" +;; +esac +""" + +initscript_by_body=initscript_by_name.replace("the_script_name","the_script_body") +# one single initscript in the InitScripts table +def initscripts(options,index): + return [ { 'initscript_fields' : { 'enabled' : True, + 'name':'the_script_name', + 'script' : initscript_by_name, + }}, + ] + +# always return 2 slices +# one has an initscript body, the other one an initscript name def slices (options,index): - return [ { 'slice_fields': {'name':'%s_pslc%d'%(login_base(index),i), - 'instantiation':'plc-instantiated', - 'url':'http://foo%d.com'%index, - 'description':'testslice number %d'%i, - 'max_nodes':2, - }, - 'usernames' : [ 'pi','tech','techuser' ], - 'nodenames' : all_nodenames(options,index), - 'initscriptname' : 'script%d'%(((i-1)%2)+1), - 'sitename' : login_base(index), - 'owner' : 'pi', - } for i in range (2*index-1,2*index+1) ] + def theslice (i): + slice_spec = { 'slice_fields': {'name':'%s_pslc%d'%(login_base(index),i), + 'instantiation':'plc-instantiated', + 'url':'http://foo%d.com'%index, + 'description':'testslice number %d'%i, + 'max_nodes':2, + }, + 'usernames' : [ 'pi','tech','techuser' ], + 'nodenames' : all_nodenames(options,index), + 'sitename' : login_base(index), + 'owner' : 'pi', + } + # odd one has an initscript_body + if i%2==1: + slice_spec['initscriptbody']=initscript_by_body + slice_spec['initscriptstamp']='the_script_body' + 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) ] def all_slicenames (options,index): return [ slice['slice_fields']['name'] for slice in slices(options,index)] @@ -258,7 +270,9 @@ def plc (options,index) : 'PLC_NET_DNS1' : 'deferred-dns-1', 'PLC_NET_DNS2' : 'deferred-dns-2', 'PLC_RESERVATION_GRANULARITY':1800, - 'PLC_OMF_ENABLED' : 'false', + # 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),