fix header comments
[sfa.git] / sfacomponent / methods / list_slices.py
1 ### $Id: list_slices.py 15428 2009-10-23 15:28:03Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfacomponent/methods/list_slices.py $
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
9 class list_slices(Method):
10     """
11     List the slices on a component      
12
13     @param cred credential string specifying the rights of the caller
14     @return list of slice names  
15     """
16
17     interfaces = ['component']
18     
19     accepts = [
20         Parameter(str, "Credential string"),
21         ]
22
23     returns = [Parameter(str, "slice name")]
24     
25     def call(self, cred, hrn, request_hash=None):
26         # This cred will be an slice cred, not a user, so we cant use it to
27         # authenticate the caller's request_hash. Let just get the caller's gid
28         # from the cred and authenticate using that
29         client_gid = Credential(string=cred).get_gid_caller()
30         client_gid_str = client_gid.save_to_string(save_parents=True)
31         self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash)
32         self.api.auth.check(cred, 'listslices')
33         slice_names = self.nodemanager.GetXIDs().keys()
34         
35         return slice_names