renamed reset_slices to reset_slice
[sfa.git] / sfa / methods / reset_slice.py
1 ### $Id: reset_slices.py 15428 2009-10-23 15:28:03Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/reset_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 from sfa.trust.auth import Auth
9 from sfa.plc.slices import Slices
10
11 class reset_slice(Method):
12     """
13     Reset the specified slice      
14
15     @param cred credential string specifying the rights of the caller
16     @param hrn human readable name of slice to instantiate
17     @return 1 is successful, faults otherwise  
18     """
19
20     interfaces = ['aggregate', 'slicemgr', 'component']
21     
22     accepts = [
23         Parameter(str, "Credential string"),
24         Parameter(str, "Human readable name of slice to instantiate"),
25         Mixed(Parameter(str, "Request hash"),
26               Parameter(None, "Request hash not specified"))
27         ]
28
29     returns = Parameter(int, "1 if successful")
30     
31     def call(self, cred, hrn, request_hash=None):
32         # This cred will be an authority cred, not a user, so we cant use it to
33         # authenticate the caller's request_hash. Let just get the caller's gid
34         # from the cred and authenticate using that
35         client_gid = Credential(string=cred).get_gid_caller()
36         client_gid_str = client_gid.save_to_string(save_parents=True)
37         self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash) 
38         self.api.auth.check(cred, 'resetslice')
39         ## XX Not yet implemented
40  
41         return 1