Cleanup dir structure.
[sfa.git] / sfa / methods / get_resources.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.trust.auth import Auth
8
9 from sfa.plc.nodes import Nodes
10
11 class get_resources(Method):
12     """
13     Get an resource specification (rspec). The rspec may describe the resources
14     available at an authority or the resources being used by a slice.      
15
16     @param cred credential string specifying the rights of the caller
17     @param hrn human readable name of the slice we are interesed in or None 
18            for an authority.  
19     """
20
21     interfaces = ['aggregate', 'slicemgr']
22     
23     accepts = [
24         Parameter(str, "Credential string"),
25         Mixed(Parameter(str, "Human readable name (hrn)"),
26               Parameter(None, "hrn not specified"))
27         ]
28
29     returns = Parameter(str, "String representatin of an rspec")
30     
31     def call(self, cred, hrn=None):
32         
33         self.api.auth.check(cred, 'listnodes')
34         nodes = Nodes(self.api)
35         if hrn:
36             rspec = nodes.get_rspec(hrn)
37         else:
38             nodes.refresh()
39             rspec = nodes['rspec']
40         
41         return rspec