+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA
+#
# a configuration module is expected:
# (*) to define a config method
# (*) that takes two arguments
# 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 'inria'
+ elif index==2: return 'princeton'
+ # index=3=>'sitea' 4=>'siteb'
+ else: return 'site%s'%chr(index+94)
+
+def sfa_root (index):
+ if index==1: return 'ple'
+ elif index==2: return 'plc'
+ else: return 'plx%s'%chr(index+94)
+
def nodes(options,index):
return [{'name':'node%d'%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',
return [ user['name'] for user in users(options)]
def sites (options,index):
- return [ {'site_fields' : {'name':'mainsite',
- 'login_base':'main',
- 'abbreviated_name':'PLanettest',
+ 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',
},
'city':'sophia',
'state':'fr',
'postalcode':'06600',
- 'country':'france',
+ 'country':'France',
},
'users' : users(options),
'nodes': nodes(options,index),
'key': public_key}}
]
+
+############################## initscripts
+initscript_by_name="""#! /bin/sh
+builtin="the_script_name"
+stamp=/tmp/$builtin.stamp
+command=$1; shift
+slicename=$1; shift
+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):
- initscripts= [ { 'initscript_fields' :
- { 'enabled' : True,
- 'name':'script1',
- 'script' : """#! /bin/sh
-(echo Starting test initscript: script1; date) > /tmp/script1.stamp
-echo "This is the stdout of the sliver initscript"
-exec 1>&2
-echo "This is the stderr of the sliver initscript"
-""",
- }},
- { '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 body, 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_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)]
return [
# local test
{ 'server_node': 'node1',
- 'server_slice' : 'main_pslc1',
+ 'server_slice' : '%s_pslc1'%login_base(index),
'client_node' : 'node1',
- 'client_slice' : 'main_pslc1',
+ 'client_slice' : '%s_pslc1'%login_base(index),
'port' : 2000,
}]
elif index == 2:
return [
# remote test
- { 'server_node': 'node1',
- 'server_slice' : 'main_pslc1',
+ { 'server_node': 'node2',
+ 'server_slice' : '%s_pslc3'%login_base(index),
'client_node' : 'node2',
- 'client_slice' : 'main_pslc2',
+ 'client_slice' : '%s_pslc4'%login_base(index),
'port' : 4000,
},
]
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=[]
slice_sequence = slices[:1] + slices + [None,]
for iterator in range(12):
for slice in slice_sequence:
- leases.append ( {'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) :
'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',
'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),
}
def sfa (options,index) :
- if index==1:
- root_auth='plc'
- else:
- root_auth='ple'
+ piuser='fake-pi%d'%index
+ regularuser='sfafakeuser%d'%index
+ slicename='fslc%d'%index
return {
- 'SFA_REGISTRY_ROOT_AUTH' : root_auth,
- 'SFA_REGISTRY_LEVEL1_AUTH' : '',
+ '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',
'SFA_SM_HOST': 'deferred-myplc-hostname',
'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,
}
-def slices_sfa (options,index):
- return [ { 'slice_fields': {'name':'main_fslc1',
+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' : 'main',
+ 'sitename' : login_base(index),
}]
-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'
+def sfa_slice_xml(options,index,piuser,slicename):
+ prefix='%s.%s'%(sfa_root(index),login_base(index))
+ hrn=prefix+'.'+slicename
+ researcher=prefix+'.'+piuser
- return ["""<record hrn="%s" type="slice" description="SFA-testing" url="http://anil.onelab.eu/"><researcher>%s</researcher></record>"""%(hrn, researcher)]
+ return ['<record hrn="%s" type="slice" description="SFA-testing" url="http://test.onelab.eu/"><researcher>%s</researcher></record>'%(hrn, researcher)]
-def sfa_person_xml(options,index):
- if index==1:
- hrn='plc.main.sfafakeuser1'
- else:
- hrn='ple.main.sfafakeuser1'
+def sfa_person_xml(options,index,regularuser):
+ prefix='%s.%s'%(sfa_root(index),login_base(index))
+ hrn=prefix+'.'+regularuser
+ mail="%s@%s"%(regularuser,domain)
+ key=public_key
- return ["""<record email="sfafakeuser1@onelab.eu" enabled="True" first_name="Anil" hrn="%s" last_name="Kumar" name="%s" type="user"><keys>%s</keys><role_ids>20</role_ids><role_ids>10</role_ids><site_ids>1</site_ids><roles>pi</roles><roles>admin</roles><sites>plc.main</sites></record>"""%(hrn,hrn,public_key)]
+ return ['<record email="%(mail)s" enabled="True" first_name="Fake" hrn="%(hrn)s" last_name="Sfa" name="%(hrn)s" type="user"><keys>%(key)s</keys><role_ids>20</role_ids><role_ids>10</role_ids><site_ids>1</site_ids><roles>pi</roles><roles>admin</roles><sites>%(prefix)s</sites></record>'%locals()]
def sfa_slice_rspec(options,index):
node_name='deferred'
- if index==1:
- netspec_name='\"plc\"'
- else:
- netspec_name='\"ple\"'
- return { 'part1' : """<?xml version="1.0" ?><Rspec><networks><NetSpec name=""",
- 'part2' : "%s"%netspec_name,
- 'part3' : """><nodes><NodeSpec cpu_min="" cpu_pct="" cpu_share="" disk_max="" init_params="" name=\"""",
- 'part4' : "%s"%node_name,
- 'part5' : """\" start_time="" type=""><net_if><IfSpec init_params="" ip_spoof="" max_kbyte="" max_rate="" min_rate="" name="True" type="ipv4"/></net_if></NodeSpec></nodes></NetSpec></networks></Rspec>"""
+ return {
+ 'part1' : '<?xml version="1.0" ?><Rspec><networks><NetSpec name=',
+ 'part2' : '%s'%sfa_root(index),
+ 'part3' : '><nodes><NodeSpec cpu_min="" cpu_pct="" cpu_share="" disk_max="" init_params="" name=\"',
+ 'part4' : '%s'%node_name,
+ 'part5' : '\" start_time="" type=""><net_if><IfSpec init_params="" ip_spoof="" max_kbyte="" max_rate="" min_rate="" name="True" type="ipv4"/></net_if></NodeSpec></nodes></NetSpec></networks></Rspec>',
}
def config (plc_specs,options):