63c8d787573a35b455c04fa58edfc0068d0f3ccf
[sfa.git] / sfa / methods / get_slices.py
1 ### $Id$
2 ### $URL$
3
4 from sfa.util.faults import *
5 from sfa.util.misc import *
6 from sfa.util.method import Method
7 from sfa.util.parameter import Parameter, Mixed
8 from sfa.trust.auth import Auth
9 from sfa.plc.slices import Slices
10
11 class get_slices(Method):
12     """
13     Get a list of instantiated slices at this authority.      
14
15     @param cred credential string specifying the rights of the caller
16     @return list of human readable slice names (hrn).  
17     """
18
19     interfaces = ['aggregate', 'slicemgr']
20     
21     accepts = [
22         Parameter(str, "Credential string"),
23         Parameter(str, "Request hash"),
24         Mixed(Parameter(str, "Request hash"),
25               Parameter(None, "Request hash not specified"))
26         ]
27
28     returns = [Parameter(str, "Human readable slice name (hrn)")]
29     
30     def call(self, cred, request_hash=None):
31         self.api.auth.authenticateCred(cred, [cred], request_hash) 
32         self.api.auth.check(cred, 'listslices')
33         slices = Slices(self.api)
34         slices.refresh()
35         return slices['hrn']