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 $
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
9 class list_slices(Method):
11 List the slices on a component
13 @param cred credential string specifying the rights of the caller
14 @return list of slice names
17 interfaces = ['component']
20 Parameter(str, "Credential string"),
23 returns = [Parameter(str, "slice name")]
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()