1 ### $Id: resolve.py 17157 2010-02-21 04:19:34Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/resolve.py $
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 Mixed(Parameter(str, "Human readable name (hrn or urn)"),
26 Parameter(list, "List of Human readable names ([hrn])")),
27 Mixed(Parameter(str, "Credential string"),
28 Parameter(list, "List of credentials)"))
33 def call(self, xrns, creds):
34 if not isinstance(xrns, types.ListType):
36 hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
38 #find valid credentials
39 valid_creds = self.api.auth.checkCredentials(creds, 'resolve')
42 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
43 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name))
45 # send the call to the right manager
46 manager = self.api.get_interface_manager()
47 return manager.resolve(self.api, xrns)