removed another bunch of references to geni
[sfa.git] / sfa / methods / list.py
1 ### $Id$
2 ### $URL$
3
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.record import SfaRecord
8 from sfa.trust.credential import Credential
9
10 class list(Method):
11     """
12     List the records in an authority. 
13
14     @param cred credential string specifying the rights of the caller
15     @param hrn human readable name of authority to list
16     @return list of record dictionaries         
17     """
18     interfaces = ['registry']
19     
20     accepts = [
21         Parameter(str, "Credential string"),
22         Parameter(str, "Human readable name (hrn)"),
23         Mixed(Parameter(str, "Human readable name of the original caller"),
24               Parameter(None, "Origin hrn not specified"))
25         ]
26
27     returns = [SfaRecord]
28     
29     def call(self, cred, hrn, origin_hrn=None):
30         user_cred = Credential(string=cred)
31         #log the call
32         if not origin_hrn:
33             origin_hrn = user_cred.get_gid_caller().get_hrn()
34         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
35        
36         # validate the cred 
37         self.api.auth.check(cred, 'list')
38         
39         # send the call to the right manager    
40         manager_base = 'sfa.managers'
41         mgr_type = self.api.config.SFA_REGISTRY_TYPE
42         manager_module = manager_base + ".registry_manager_%s" % mgr_type
43         manager = __import__(manager_module, fromlist=[manager_base])
44         return manager.list(self.api, hrn)