X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Fconfig_default.py;h=1adf9b79131abaa93994c8c0b92909d473e049f9;hb=86060c0d1d30f491bda3f34be1f4fa7a16230a7d;hp=e1a3a7597b47b8670a6abc21cd9e58fcd527d512;hpb=72dfe45e8b716c1c599f8b50299db5ad8b898fd0;p=tests.git diff --git a/system/config_default.py b/system/config_default.py index e1a3a75..1adf9b7 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -1,3 +1,6 @@ +# Thierry Parmentelat +# Copyright (C) 2010 INRIA +# # a configuration module is expected: # (*) to define a config method # (*) that takes two arguments @@ -7,7 +10,18 @@ # values like 'hostname', 'ip' and the like are rewritten later with a TestPool object -reservation_granularity=180 +domain="onelab.eu" + +### for the sfa dual setup +def login_base (index): + if index==1: return 'inri' + elif index==2: return 'princ' + # index=3=>'sitea' 4=>'siteb' + else: return 'site%s'%chr(index+94) + +def sfa_root (index): + # pla, plb, ... + return 'pl%s'%chr(index+96) def nodes(options,index): return [{'name':'node%d'%index, @@ -32,7 +46,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', @@ -77,17 +90,21 @@ def all_usernames (options): return [ user['name'] for user in users(options)] def sites (options,index): - return [ {'site_fields' : {'name':'mainsite', - 'login_base':'main', - 'abbreviated_name':'PLanettest', + 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', 'state':'fr', 'postalcode':'06600', - 'country':'france', + 'country':'France', }, 'users' : users(options), 'nodes': nodes(options,index), @@ -132,33 +149,72 @@ def keys (options,index): 'key': public_key}} ] + +############################## initscripts +initscript_by_name="""#!/bin/bash +command=$1; shift +slicename=$1; shift +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): - initscripts= [ { 'initscript_fields' : - { 'enabled' : True, - 'name':'script1', - 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 1; date) > /tmp/script1.stamp \n ', - }}, - { 'initscript_fields' : - { 'enabled' : True, - 'name':'script2', - 'script' : '#! /bin/sh\n (echo Starting test initscript: Stage 2; date) > /tmp/script2.stamp \n ', - }}, - ] - return initscripts + 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':'main_pslc%d'%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, - 'sitename' : 'main', - 'owner' : 'pi', - } for i in range (2*index-1,2*index+1) ] + def theslice (i): + slice_spec = { 'slice_fields': {'name':'%s_slpl%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)] @@ -168,18 +224,18 @@ def tcp_tests (options,index): return [ # local test { 'server_node': 'node1', - 'server_slice' : 'main_pslc1', + 'server_slice' : '%s_slpl1'%login_base(index), 'client_node' : 'node1', - 'client_slice' : 'main_pslc1', + 'client_slice' : '%s_slpl1'%login_base(index), 'port' : 2000, }] elif index == 2: return [ # remote test - { 'server_node': 'node1', - 'server_slice' : 'main_pslc1', + { 'server_node': 'node2', + 'server_slice' : '%s_slpl3'%login_base(index), 'client_node' : 'node2', - 'client_slice' : 'main_pslc2', + 'client_slice' : '%s_slpl4'%login_base(index), 'port' : 4000, }, ] @@ -187,34 +243,36 @@ def tcp_tests (options,index): 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 +# if they are smaller than one year, they are relative to the current time, expressed in grains # 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(100): + for iterator in range(12): for slice in slice_sequence: - leases += { 'slice' : slice, 't_from':counter,'t_until':counter+reservation_granularity} - counter += reservation_granularity + leases.append ( {'slice' : slice, 't_from':counter,'t_until':counter+1} ) + counter += 1 return leases def plc (options,index) : return { - 'name' : 'onetest%d'%index, + 'index' : index, + 'name' : 'plctest%d'%index, # as of yet, not sure we can handle foreign hosts, but this is required though - 'hostname' : 'deferred-myplc-hostbox-%d'%index, + 'host_box' : 'deferred-myplc-hostbox-%d'%index, # set these two items to run within a vserver 'vservername': 'deferred-vservername', 'vserverip': 'deferred-vserverip', 'role' : 'root', + 'PLC_NAME' : 'Regression TestLab', 'PLC_ROOT_USER' : 'root@test.onelab.eu', 'PLC_ROOT_PASSWORD' : 'test++', - 'PLC_NAME' : 'Regression TestLab', + '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', @@ -222,7 +280,10 @@ def plc (options,index) : 'PLC_BOOT_HOST' : 'deferred-myplc-hostname', 'PLC_NET_DNS1' : 'deferred-dns-1', 'PLC_NET_DNS2' : 'deferred-dns-2', - 'PLC_RESERVATION_GRANULARITY':reservation_granularity, + 'PLC_RESERVATION_GRANULARITY':1800, + # 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), @@ -233,13 +294,13 @@ def plc (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' : '', + # the default is to use AMs in the various aggregates.xml + # stack config_sfamesh to point to SMs instead + 'neighbours-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', @@ -249,55 +310,51 @@ 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, + # details of the slices to create + # xxx framework is ready to use pg rspecs, but code is not yet + 'sfa_slice_specs' : [ sfa_slice_spec(options,index,mode) + for mode in ['pl']], } -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', - }] +# subindex is 0 (pl slice) or 1 (pg slice) +def sfa_slice_spec (options,index,mode): + the_login_base=login_base(index) + piuser='fake-pi%d'%index + regularuser='sfauser%d%s'%(index,mode) + slicename='slsfa%d%s'%(index,mode) + prefix='%s.%s'%(sfa_root(index),the_login_base) + hrn=prefix+'.'+slicename + researcher=prefix+'.'+piuser + slice_add_xml = ''' +%s'''%(hrn, researcher) -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' + mail="%s@%s"%(regularuser,domain) + key=public_key + slice_person_xml =''' +%(key)s2010 +1piadmin%(prefix)s'''%locals() - return ["""%s"""%(hrn, researcher)] + return { 'slice_fields': {'name':'%s_%s'%(the_login_base,slicename), + 'url':'http://foo%d@foo.com'%index, + 'description':'SFA-testing', + 'max_nodes':2, + }, + 'login_base' : the_login_base, + 'piuser' : piuser, + 'regularuser':regularuser, + 'domain':domain, + 'usernames' : [ (regularuser,'key1') ], + 'nodenames' : all_nodenames(options,index), + 'sitename' : the_login_base, + 'slicename' : slicename, + 'slice_add_xml' : slice_add_xml, + 'slice_person_xml' : slice_person_xml, + 'mode':mode, + } -def sfa_person_xml(options,index): - if index==1: - hrn='plc.main.sfafakeuser1' - else: - hrn='ple.main.sfafakeuser1' - - return ["""%s20101piadminplc.main"""%(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' : """""" - } - def config (plc_specs,options): result=plc_specs for i in range (options.size):