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(str, "Credential string"),
31 Parameter(dict, "Record dictionary containing record fields")
34 returns = Parameter(int, "String representation of gid object")
36 def call(self, cred, record, origin_hrn=None):
37 user_cred = Credential(string=cred)
41 origin_hrn = user_cred.get_gid_caller().get_hrn()
45 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
48 self.api.auth.check(cred, "register")
50 #send the call to the right manager
51 manager_base = 'sfa.managers'
52 mgr_type = self.api.config.SFA_REGISTRY_TYPE
53 manager_module = manager_base + ".registry_manager_%s" % mgr_type
54 manager = __import__(manager_module, fromlist=[manager_base])
55 return manager.register(self.api, record)