4 from sfa.util.faults import *
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7 from sfa.util.debug import log
8 from sfa.trust.credential import Credential
9 from sfa.util.record import SfaRecord
11 class resolve(Method):
15 @param cred credential string authorizing the caller
16 @param hrn human readable name to resolve (hrn or urn)
17 @return a list of record dictionaries or empty list
20 interfaces = ['registry']
23 Parameter(str, "Credential string"),
24 Mixed(Parameter(str, "Human readable name (hrn or urn)"),
25 Parameter(list, "List of Human readable names ([hrn])"))
30 def call(self, cred, xrn, origin_hrn=None):
31 user_cred = Credential(string=cred)
35 origin_hrn = user_cred.get_gid_caller().get_hrn()
36 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
39 self.api.auth.check(cred, 'resolve')
40 # send the call to the right manager
41 manager_base = 'sfa.managers'
42 mgr_type = self.api.config.SFA_REGISTRY_TYPE
43 manager_module = manager_base + ".registry_manager_%s" % mgr_type
44 manager = __import__(manager_module, fromlist=[manager_base])
45 return manager.resolve(self.api, xrn, origin_hrn=origin_hrn)