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
12 @param cred credential string authorizing the caller
13 @param hrn human readable name to resolve (hrn or urn)
14 @return a list of record dictionaries or empty list
17 interfaces = ['registry']
19 # should we not accept an optional 'details' argument ?
21 Mixed(Parameter(str, "Human readable name (hrn or urn)"),
22 Parameter(list, "List of Human readable names ([hrn])")),
23 Mixed(Parameter(str, "Credential string"),
24 Parameter(list, "List of credentials)")),
25 Parameter(dict, "options"),
28 # xxx used to be [SfaRecord]
29 returns = [Parameter(dict, "registry record")]
31 def call(self, xrns, creds, options=None):
32 if options is None: options={}
33 # use details=False by default, only when explicitly specified do we want
34 # to mess with the testbed details
35 if 'details' in options: details=options['details']
38 if not isinstance(xrns, list):
39 type = Xrn(xrns).get_type()
41 hrns = [urn_to_hrn(xrn)[0] for xrn in xrns]
42 #find valid credentials
43 valid_creds = self.api.auth.checkCredentials(creds, 'resolve')
46 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
47 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrns, self.name))
49 # send the call to the right manager
50 return self.api.manager.Resolve(self.api, xrns, type, details=details)