use self.get_auth_info
[sfa.git] / geni / methods / get_resources.py
1 ### $Id$
2 ### $URL$
3
4 from geni.util.faults import *
5 from geni.util.method import Method
6 from geni.util.parameter import Parameter, Mixed
7 from geni.util.auth import Auth
8 from geni.util.nodes import Nodes
9
10 class get_resources(Method):
11     """
12     Get an resource specification (rspec). The rspec may describe the resources
13     available at an authority or the resources being used by a slice.      
14
15     @param cred credential string specifying the rights of the caller
16     @param hrn human readable name of the slice we are interesed in or None 
17            for an authority.  
18     """
19
20     interfaces = ['aggregate', 'slicemgr']
21     
22     accepts = [
23         Parameter(str, "Credential string"),
24         Mixed(Parameter(str, "Human readable name (hrn)"),
25               Parameter(None, "hrn not specified"))
26         ]
27
28     returns = Parameter(str, "String representatin of an rspec")
29     
30     def call(self, cred, hrn=None):
31         
32         self.api.auth.check(cred, 'listnodes')
33         nodes = Nodes(self.api)
34         if hrn:
35             rspec = nodes.get_rspec(hrn)
36         else:
37             nodes.refresh()
38             rspec = nodes['rspec']
39         
40         return rspec