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