3 from sfa.util.faults import *
4 from sfa.util.xrn import Xrn, urn_to_hrn
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7 from sfa.trust.credential import Credential
8 from sfa.util.record import SfaRecord
10 class Resolve(Method):
14 @param cred credential string authorizing the caller
15 @param hrn human readable name to resolve (hrn or urn)
16 @return a list of record dictionaries or empty list
19 interfaces = ['registry']
22 Mixed(Parameter(str, "Human readable name (hrn or urn)"),
23 Parameter(list, "List of Human readable names ([hrn])")),
24 Mixed(Parameter(str, "Credential string"),
25 Parameter(list, "List of credentials)"))
30 def call(self, xrns, creds):
32 if not isinstance(xrns, types.ListType):
33 type = Xrn(xrns).get_type()
35 hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
36 #find valid credentials
37 valid_creds = self.api.auth.checkCredentials(creds, 'resolve')
40 origin_hrn = Credential(string=valid_creds[0]).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))
43 # send the call to the right manager
44 manager = self.api.get_interface_manager()
45 return manager.resolve(self.api, xrns, type)