1 ### $Id: delete_slice.py 15428 2009-10-23 15:28:03Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfacomponent/methods/delete_slice.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 delete_slice(Method):
11 Delete the specified slice
13 @param cred credential string specifying the rights of the caller
14 @param hrn human readable name of slice to instantiate
15 @return 1 is successful, faults otherwise
18 interfaces = ['component']
21 Parameter(str, "Credential string"),
22 Parameter(str, "Human readable name of slice to instantiate"),
23 Mixed(Parameter(str, "Request hash"),
24 Parameter(None, "Request hash not specified"))
27 returns = [Parameter(int, "1 if successful")]
29 def call(self, cred, hrn, request_hash=None):
30 # This cred will be an slice cred, not a user, so we cant use it to
31 # authenticate the caller's request_hash. Let just get the caller's gid
32 # from the cred and authenticate using that
33 client_gid = Credential(string=cred).get_gid_caller()
34 client_gid_str = client_gid.save_to_string(save_parents=True)
35 self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash)
36 self.api.auth.check(cred, 'deleteslice')
37 slicename = hrn_to_pl_slicename(hrn)
38 self.api.nodemanager.Destroy(slicename)