initial checkin
[sfa.git] / sfacomponent / methods / delete_slice.py
1 ### $Id: start_slice.py 15428 2009-10-23 15:28:03Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/start_slice.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 delete_slice(Method):
10     """
11     Delete the specified slice      
12
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  
16     """
17
18     interfaces = ['component']
19     
20     accepts = [
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"))
25         ]
26
27     returns = [Parameter(int, "1 if successful")]
28     
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         self.api.nodemanager.Destroy(hrn)
38         
39         return 1