X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Fconfig_default.py;h=16a4e9059f89d7e1e1c63739749b1dff3e95f414;hb=4752a573406d72f89495e6e6b6fadd0ac02e0aab;hp=50a70a69cdb3ee515d79f5344dfc933fc180838f;hpb=17b264d1abdc1e9f7bdfcb093f29432a394a7d68;p=tests.git diff --git a/system/config_default.py b/system/config_default.py index 50a70a6..16a4e90 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -10,6 +10,8 @@ # values like 'hostname', 'ip' and the like are rewritten later with a TestPool object +domain="onelab.eu" + ### for the sfa dual setup def login_base (index): if index==1: return 'inria' @@ -46,7 +48,6 @@ def all_nodenames (options,index): return [ node['name'] for node in nodes(options,index)] def users (options) : - domain="onelab.eu" return [ {'name' : 'pi', 'keynames' : [ 'key1' ], 'user_fields' : {'first_name':'PI', 'last_name':'PI', 'enabled':'True', @@ -91,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', @@ -146,52 +151,72 @@ 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/bash 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 +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 +} +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_code=initscript_by_name.replace("the_script_name","the_script_code") +# 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 code, 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.com', - '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','user','techuser' ], + 'nodenames' : all_nodenames(options,index), + 'sitename' : login_base(index), + 'owner' : 'pi', + } + # odd one has an initscript_code + if i%2==1: + 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 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)] @@ -209,10 +234,10 @@ def tcp_tests (options,index): elif index == 2: return [ # remote test - { 'server_node': 'node1', - 'server_slice' : '%s_pslc1'%login_base(index), + { 'server_node': 'node2', + 'server_slice' : '%s_pslc3'%login_base(index), 'client_node' : 'node2', - 'client_slice' : '%s_pslc2'%login_base(index), + 'client_slice' : '%s_pslc4'%login_base(index), 'port' : 4000, }, ] @@ -235,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, @@ -248,7 +274,7 @@ def plc (options,index) : 'PLC_SLICE_PREFIX' : 'auto', 'PLC_SHORTNAME' : 'Rlab', 'PLC_MAIL_ENABLED':'false', - 'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@sophia.inria.fr', + 'PLC_MAIL_SUPPORT_ADDRESS' : 'thierry.parmentelat@inria.fr', 'PLC_DB_HOST' : 'deferred-myplc-hostname', 'PLC_DB_PASSWORD' : 'mnbvcxzlkjhgfdsapoiuytrewq', 'PLC_API_HOST' : 'deferred-myplc-hostname', @@ -257,7 +283,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), @@ -268,8 +296,12 @@ def plc (options,index) : } def sfa (options,index) : + piuser='fake-pi%d'%index + regularuser='sfafakeuser%d'%index + slicename='fslc%d'%index return { 'SFA_REGISTRY_ROOT_AUTH' : sfa_root(index), + 'SFA_INTERFACE_HRN' : sfa_root(index), # 'SFA_REGISTRY_LEVEL1_AUTH' : '', 'SFA_REGISTRY_HOST' : 'deferred-myplc-hostname', 'SFA_AGGREGATE_HOST': 'deferred-myplc-hostname', @@ -280,35 +312,46 @@ def sfa (options,index) : '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) + 'SFA_API_DEBUG': True, + 'sfa_slice_specs' : sfa_slice_specs(options,index,slicename,regularuser), + 'sfa_slice_xml' : sfa_slice_xml(options,index,piuser,slicename), + 'sfa_person_xml' : sfa_person_xml(options,index,regularuser), + 'sfa_slice_rspec' : sfa_slice_rspec(options,index), + 'login_base' : login_base(index), + 'piuser' : piuser, + '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 slices_sfa (options,index): - return [ { 'slice_fields': {'name':'%s_fslc1'%login_base(index), +def sfa_slice_specs (options,index,slicename,regularuser): + return [ { 'slice_fields': {'name':'%s_%s'%(login_base(index),slicename), 'url':'http://foo%d@foo.com'%index, 'description':'SFA-testing', 'max_nodes':2, }, - 'usernames' : [ ('sfafakeuser1','key1') ], + 'usernames' : [ (regularuser,'key1') ], 'nodenames' : all_nodenames(options,index), 'sitename' : login_base(index), }] -def sfa_slice_xml(options,index): +def sfa_slice_xml(options,index,piuser,slicename): prefix='%s.%s'%(sfa_root(index),login_base(index)) - hrn=prefix+'.fslc1' - researcher=prefix+'.fake-pi1' + hrn=prefix+'.'+slicename + researcher=prefix+'.'+piuser return ['%s'%(hrn, researcher)] -def sfa_person_xml(options,index): +def sfa_person_xml(options,index,regularuser): prefix='%s.%s'%(sfa_root(index),login_base(index)) - hrn=prefix+'.sfafakeuser1' + hrn=prefix+'.'+regularuser + mail="%s@%s"%(regularuser,domain) + key=public_key - return ['%s20101piadmin%s'%(hrn,hrn,public_key,prefix)] + return ['%(key)s20101piadmin%(prefix)s'%locals()] def sfa_slice_rspec(options,index): node_name='deferred'