- if self.rspec_style()=='pg': return "-r protogeni"
- else: return ""
-
- def sfi_path (self):
- return "/root/sfi/%s"%self.slicename
-
- def locate_key(self):
- for username,keyname in self.sfa_slice_spec['usernames']:
- key_spec=self.test_plc.locate_key(keyname)
- test_key=TestKey(self.test_plc,key_spec)
- publickey=test_key.publicpath()
- privatekey=test_key.privatepath()
- if os.path.isfile(publickey) and os.path.isfile(privatekey):
- found=True
- return (found,privatekey)
-
- # dir_name is local and will be pushed later on by TestPlc
- # by default set SFI_USER to the pi, we'll overload this
- # on the command line when needed
- def sfi_config (self,dir_name):
- plc_spec=self.test_plc.plc_spec
- sfa_spec=self.sfa_spec
- sfa_slice_spec=self.sfa_slice_spec
- # store private key for sfa pi user
- file_name=dir_name + os.sep + self.qualified_hrn (self.piuser) + '.pkey'
- fileconf=open(file_name,'w')
- fileconf.write (plc_spec['keys'][0]['private'])
- fileconf.close()
- utils.header ("(Over)wrote %s"%file_name)
- # store private key for sfa regular user
- file_name=dir_name + os.sep + self.qualified_hrn(self.regularuser) + '.pkey'
- fileconf=open(file_name,'w')
- fileconf.write (plc_spec['keys'][1]['private'])
- fileconf.close()
- utils.header ("(Over)wrote %s"%file_name)
- #
- file_name=dir_name + os.sep + self.addpersonfile()
- fileconf=open(file_name,'w')
- fileconf.write(sfa_slice_spec['slice_person_xml'])
- fileconf.write('\n')
- fileconf.close()
- utils.header ("(Over)wrote %s"%file_name)
- #
- file_name=dir_name + os.sep + 'sfi_config'
- fileconf=open(file_name,'w')
- SFI_AUTH="%s"%(self.site_hrn())
- fileconf.write ("SFI_AUTH='%s'"%SFI_AUTH)
- fileconf.write('\n')
- SFI_USER=SFI_AUTH + '.' + self.piuser
- fileconf.write ("SFI_USER='%s'"%SFI_USER)
- fileconf.write('\n')
- SFI_REGISTRY='http://' + sfa_spec['SFA_REGISTRY_HOST'] + ':12345/'
- fileconf.write ("SFI_REGISTRY='%s'"%SFI_REGISTRY)
- fileconf.write('\n')
- SFI_SM='http://' + sfa_spec['SFA_SM_HOST'] + ':12347/'
- fileconf.write ("SFI_SM='%s'"%SFI_SM)
- fileconf.write('\n')
- fileconf.close()
- utils.header ("(Over)wrote %s"%file_name)
- #
- file_name=dir_name + os.sep + self.addslicefile()
- fileconf=open(file_name,'w')
- fileconf.write(sfa_slice_spec['slice_add_xml'])
- fileconf.write('\n')
- utils.header ("(Over)wrote %s"%file_name)
- fileconf.close()
-
- # user management
- def sfa_add_user (self, options):
- return TestUserSfa(self.test_plc, self.sfa_slice_spec, self).add_user()
- def sfa_update_user (self, options):
- return TestUserSfa(self.test_plc, self.sfa_slice_spec, self).update_user()
- def sfa_delete_user (self, options):
- return TestUserSfa(self.test_plc, self.sfa_slice_spec, self).delete_user()
-
- # run as pi
- def sfi_pi (self, command):
- return "sfi.py -d %s -u %s %s"%(self.sfi_path(),self.qualified_hrn(self.piuser), command,)
- # the sfi.py command line option to run as a regular user
- def sfi_user (self, command):
- return "sfi.py -d %s -u %s %s"%(self.sfi_path(),self.qualified_hrn(self.regularuser), command,)