1 from sfa.util.xrn import Xrn, urn_to_hrn
2 from sfa.util.method import Method
4 from sfa.trust.credential import Credential
6 from sfa.storage.parameter import Parameter, Mixed
13 @param cred credential string authorizing the caller
14 @param hrn human readable name to resolve (hrn or urn)
15 @return a list of record dictionaries or empty list
18 interfaces = ['registry']
20 # should we not accept an optional 'details' argument ?
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)")),
26 Parameter(dict, "options"),
29 # xxx used to be [SfaRecord]
30 returns = [Parameter(dict, "registry record")]
32 def call(self, xrns, creds, options=None):
35 # use details=False by default, only when explicitly specified do we want
36 # to mess with the testbed details
37 if 'details' in options:
38 details = options['details']
42 if not isinstance(xrns, list):
43 type = Xrn(xrns).get_type()
45 hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
46 # find valid credentials
47 valid_creds = self.api.auth.checkCredentials(creds, 'resolve')
50 origin_hrn = Credential(
51 string=valid_creds[0]).get_gid_caller().get_hrn()
52 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s" %
53 (self.api.interface, origin_hrn, hrns, self.name))
55 # send the call to the right manager
56 return self.api.manager.Resolve(self.api, xrns, type, details=details)