From: Thierry Parmentelat Date: Thu, 31 May 2012 16:22:06 +0000 (+0200) Subject: use current sfi with --extra X-Git-Tag: tests-5.1-5~6 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ee198177f39ef59b1bfed86a2d7a09c9e8d1a976;p=tests.git use current sfi with --extra --- diff --git a/system/TestSliceSfa.py b/system/TestSliceSfa.py index 1ddc174..2c90359 100644 --- a/system/TestSliceSfa.py +++ b/system/TestSliceSfa.py @@ -25,8 +25,8 @@ class TestSliceSfa: self.slicename=self.sfa_slice_spec['slicename'] self.login_base=self.sfa_slice_spec['login_base'] - def name(self): - return self.sfa_slice_spec['slice_fields']['name'] + def plc_name(self): + return self.sfa_slice_spec['plc_slicename'] def rspec_style (self): return self.sfa_slice_spec['rspec_style'] @@ -162,9 +162,9 @@ class TestSliceSfa: def sfa_add_slice(self,options): "run sfi add (on Registry) from slice.xml" sfi_options="add" - for (k,v) in self.sfa_slice_spec['slice_sfi_options'].items(): - sfi_options += " %s %s"%(k,v) - return self.test_plc.run_in_guest(self.sfi_pi("%s"%(sfi_options)))==0 + for opt in self.sfa_slice_spec['slice_sfi_options']: + sfi_options += " %s"%(opt) + return self.test_plc.run_in_guest(self.sfi_pi(sfi_options))==0 # run as user def sfa_discover(self,options): @@ -188,8 +188,7 @@ class TestSliceSfa: # all local nodes in slice ? def sfa_check_slice_plc (self,options): "check sfa_create_slice at the plcs - all local nodes should be in slice" - slice_fields = self.sfa_slice_spec['slice_fields'] - slice_name = slice_fields['name'] + slice_name = self.plc_name() slice=self.test_plc.apiserver.GetSlices(self.test_plc.auth_root(), slice_name)[0] nodes=self.test_plc.apiserver.GetNodes(self.test_plc.auth_root(), {'peer_id':None}) result=True @@ -220,7 +219,7 @@ class TestSliceSfa: # locate a key (found,remote_privatekey)=self.locate_key() if not found : - utils.header("WARNING: Cannot find a valid key for slice %s"%self.name()) + utils.header("WARNING: Cannot find a valid key for slice %s"%self.plc_name()) return False # convert nodenames to real hostnames @@ -231,22 +230,22 @@ class TestSliceSfa: (site_spec,node_spec) = self.test_plc.locate_node(nodename) tocheck.append(node_spec['node_fields']['hostname']) - utils.header("checking ssh access into slice %s on nodes %r"%(self.name(),tocheck)) + utils.header("checking ssh access into slice %s on nodes %r"%(self.plc_name(),tocheck)) utils.header("max timeout is %d minutes, silent for %d minutes (period is %s)"%\ (timeout_minutes,silent_minutes,period)) while tocheck: for hostname in tocheck: (site_spec,node_spec) = self.test_plc.locate_hostname(hostname) - date_test_ssh = TestSsh (hostname,key=remote_privatekey,username=self.name()) + date_test_ssh = TestSsh (hostname,key=remote_privatekey,username=self.plc_name()) command = date_test_ssh.actual_command("echo hostname ; hostname; echo id; id; echo uname -a ; uname -a") date = utils.system (command, silent=datetime.datetime.now() < graceout) if date==0: - utils.header("Successfuly entered slice %s on %s"%(self.name(),hostname)) + utils.header("Successfuly entered slice %s on %s"%(self.plc_name(),hostname)) tocheck.remove(hostname) else: # real nodes will have been checked once in case they're up - skip if not if TestNode.is_real_model(node_spec['node_fields']['model']): - utils.header("WARNING : Checking slice %s on real node %s skipped"%(self.name(),hostname)) + utils.header("WARNING : Checking slice %s on real node %s skipped"%(self.plc_name(),hostname)) tocheck.remove(hostname) # nm restart after first failure, if requested if options.forcenm and hostname not in restarted: @@ -263,7 +262,7 @@ class TestSliceSfa: return True if datetime.datetime.now() > timeout: for hostname in tocheck: - utils.header("FAILURE to ssh into %s@%s"%(self.name(),hostname)) + utils.header("FAILURE to ssh into %s@%s"%(self.plc_name(),hostname)) return False # wait for the period time.sleep (period) diff --git a/system/TestUserSfa.py b/system/TestUserSfa.py index 2a40afe..ccd07c3 100644 --- a/system/TestUserSfa.py +++ b/system/TestUserSfa.py @@ -22,14 +22,14 @@ class TestUserSfa: # xxx todo - not the right place any longer - or is it ? def add_user (self): - sfi_add_options = self.sfa_slice_spec['person_sfi_options'] + sfi_add_options = self.sfa_slice_spec['user_sfi_options'] + user_hrn = self.sfa_slice_spec['user_hrn'] command="sfi -d %s add"%(self.sfi_path()) - for (opt,val) in sfi_add_options.items(): - command += " %s %s"%(opt,val) + for opt in sfi_add_options: + command += " %s"%(opt,) # handle key separately because of embedded whitespace # hack - the user's pubkey is avail from his hrn - hrn=sfi_add_options['-x'] - command += " -k %s/%s.pub"%(self.sfi_path(),hrn) + command += " -k %s/%s.pub"%(self.sfi_path(),user_hrn) return self.test_plc.run_in_guest(command)==0 def update_user (self): diff --git a/system/config_default.py b/system/config_default.py index c4ededc..690e532 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -519,25 +519,25 @@ def sfa_slice_spec (options,index,rspec_style): mail="%s@%s"%(regularuser,domain) # passed to sfi # -k gets computed later on from the hrn (i.e. from the '-x' key..) - person_options = { '-t': 'user', - '-x': user_hrn, - '-e': mail, - '-f': "Fake", - '-l': "SFA-style-%s"%rspec_style, - } + user_sfi_options = [ '--type','user', + '--xrn',user_hrn, + '--email',mail, + # xxx + '--extra',"enabled=true", + '--extra',"first_name=Fake", + '--extra',"last_name=SFA-style-%s"%rspec_style, + ] - slice_options = { '-t': 'slice', - '-x': hrn, - '-d': "SFA-testing-%s"%rspec_style, - '-u': "http://test.onelab.eu/", - '-r': user_hrn, - } - - return { 'slice_fields': {'name':'%s_%s'%(the_login_base,slicename), - 'url':'http://foo%d@foo.com'%index, - 'description':'SFA-testing', - 'max_nodes':2, - }, + slice_sfi_options = [ '--type', 'slice', + '--xrn', hrn, + '--researchers', user_hrn, + # xxx + '--extra', "description=SFA-testing-%s"%rspec_style, + '--extra', "url=http://slice%d.test.onelab.eu/"%index, + '--extra', "max_nodes=2", + ] + + return { 'plc_slicename': '%s_%s'%(the_login_base,slicename), 'login_base' : the_login_base, 'piuser' : piuser, 'pimail' : pimail, @@ -550,13 +550,9 @@ def sfa_slice_spec (options,index,rspec_style): 'sitename' : the_login_base, 'slicename' : slicename, 'rspec_style':rspec_style, - 'person_sfi_options': person_options, - 'slice_sfi_options': slice_options, -# # these get exported under the sfi directory -# 'pi_private_key':private_key3, -# 'pi_public_key':public_key3, -# 'user_private_key':private_key4, -# 'user_public_key':public_key4, + 'user_sfi_options': user_sfi_options, + 'user_hrn': user_hrn, + 'slice_sfi_options': slice_sfi_options, }