5 from sfa.util.faults import *
6 from sfa.util.namespace import *
7 from sfa.util.method import Method
8 from sfa.util.parameter import Parameter, Mixed
9 from sfa.util.debug import log
10 from sfa.trust.credential import Credential
11 from sfa.util.record import SfaRecord
13 class resolve(Method):
17 @param cred credential string authorizing the caller
18 @param hrn human readable name to resolve (hrn or urn)
19 @return a list of record dictionaries or empty list
22 interfaces = ['registry']
25 Parameter(str, "Credential string"),
26 Mixed(Parameter(str, "Human readable name (hrn or urn)"),
27 Parameter(list, "List of Human readable names ([hrn])"))
32 def call(self, cred, xrns, origin_hrn=None):
33 user_cred = Credential(string=cred)
34 if not isinstance(xrns, types.ListType):
36 hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
40 origin_hrn = user_cred.get_gid_caller().get_hrn()
41 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name))
44 self.api.auth.check(cred, 'resolve')
45 # send the call to the right manager
46 manager_base = 'sfa.managers'
47 mgr_type = self.api.config.SFA_REGISTRY_TYPE
48 manager_module = manager_base + ".registry_manager_%s" % mgr_type
49 manager = __import__(manager_module, fromlist=[manager_base])
50 return manager.resolve(self.api, xrns, origin_hrn=origin_hrn)