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 GeniRecord
10 from sfa.util.genitable import GeniTable
11 from sfa.util.debug import log
12 from sfa.trust.auth import Auth
13 from sfa.trust.gid import create_uuid
14 from sfa.trust.credential import Credential
16 class register(Method):
18 Register an object with the registry. In addition to being stored in the
19 Geni database, the appropriate records will also be created in the
22 @param cred credential string
23 @param record_dict dictionary containing record fields
25 @return gid string representation
28 interfaces = ['registry']
31 Parameter(str, "Credential string"),
32 Parameter(dict, "Record dictionary containing record fields")
35 returns = Parameter(int, "String representation of gid object")
37 def call(self, cred, record, origin_hrn=None):
38 user_cred = Credential(string=cred)
42 origin_hrn = user_cred.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))
49 self.api.auth.check(cred, "register")
51 #send the call to the right manager
52 manager_base = 'sfa.managers'
53 mgr_type = self.api.config.SFA_REGISTRY_TYPE
54 manager_module = manager_base + ".registry_manager_%s" % mgr_type
55 manager = __import__(manager_module, fromlist=[manager_base])
56 return manager.register(self.api, record)