removed another bunch of references to geni
[sfa.git] / sfa / methods / resolve.py
1 ### $Id$
2 ### $URL$
3 import traceback
4 from sfa.util.faults import *
5 from sfa.util.method import Method
6 from sfa.util.parameter import Parameter, Mixed
7 from sfa.util.debug import log
8 from sfa.trust.credential import Credential
9 from sfa.util.record import SfaRecord
10
11 class resolve(Method):
12     """
13     Resolve a record.
14
15     @param cred credential string authorizing the caller
16     @param hrn human readable name to resolve
17     @return a list of record dictionaries or empty list     
18     """
19
20     interfaces = ['registry']
21     
22     accepts = [
23         Parameter(str, "Credential string"),
24         Mixed(Parameter(str, "Human readable name (hrn)"),
25               Parameter(list, "List of Human readable names ([hrn])"))  
26         ]
27
28     returns = [SfaRecord]
29     
30     def call(self, cred, hrn, origin_hrn=None):
31         user_cred = Credential(string=cred)
32
33         #log the call
34         if not origin_hrn:
35             origin_hrn = user_cred.get_gid_caller().get_hrn()
36         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
37  
38         # validate the cred
39         self.api.auth.check(cred, 'resolve')
40         # send the call to the right manager
41         manager_base = 'sfa.managers'
42         mgr_type = self.api.config.SFA_REGISTRY_TYPE
43         manager_module = manager_base + ".registry_manager_%s" % mgr_type
44         manager = __import__(manager_module, fromlist=[manager_base])
45         return manager.resolve(self.api, hrn, origin_hrn=origin_hrn)
46
47
48