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.util.debug import log
11 from sfa.trust.auth import Auth
12 from sfa.trust.gid import create_uuid
13 from sfa.trust.credential import Credential
15 class Register(Method):
17 Register an object with the registry. In addition to being stored in the
18 SFA database, the appropriate records will also be created in the
21 @param cred credential string
22 @param record_dict dictionary containing record fields
24 @return gid string representation
27 interfaces = ['registry']
30 Parameter(dict, "Record dictionary containing record fields"),
31 Mixed(Parameter(str, "Credential string"),
32 Parameter(type([str]), "List of credentials")),
35 returns = Parameter(int, "String representation of gid object")
37 def call(self, record, creds):
39 valid_creds = self.api.auth.checkCredentials(creds, 'register')
42 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
47 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
49 manager = self.api.get_interface_manager()
51 return manager.register(self.api, record)