1 ### $Id: register.py 16477 2010-01-05 16:31:37Z thierry $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/register.py $
4 from sfa.trust.certificate import Keypair, convert_public_key
5 from sfa.trust.gid import *
6 from sfa.util.faults import *
7 from sfa.util.method import Method
8 from sfa.util.parameter import Parameter, Mixed
9 from sfa.util.record import SfaRecord
10 from sfa.trust.auth import Auth
11 from sfa.trust.gid import create_uuid
12 from sfa.trust.credential import Credential
14 class Register(Method):
16 Register an object with the registry. In addition to being stored in the
17 SFA database, the appropriate records will also be created in the
20 @param cred credential string
21 @param record_dict dictionary containing record fields
23 @return gid string representation
26 interfaces = ['registry']
29 Parameter(dict, "Record dictionary containing record fields"),
30 Mixed(Parameter(str, "Credential string"),
31 Parameter(type([str]), "List of credentials")),
34 returns = Parameter(int, "String representation of gid object")
36 def call(self, record, creds):
38 valid_creds = self.api.auth.checkCredentials(creds, 'register')
41 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
46 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
48 manager = self.api.get_interface_manager()
50 return manager.register(self.api, record)