add request_hash argumet to more method calls
[sfa.git] / sfa / methods / stop_slice.py
1 ### $Id$
2 ### $URL$
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 stop_slice(Method):
12     """
13     Stop 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']
21     
22     accepts = [
23         Parameter(str, "Credential string"),
24         Parameter(str, "Human readable name of slice to instantiate"),
25         Parameter(str, "Request hash")
26         ]
27
28     returns = Parameter(int, "1 if successful")
29     
30     def call(self, cred, hrn, request_hash):
31         # This cred will be an slice cred, not a user, so we cant use it to
32         # authenticate the caller's request_hash. Let just get the caller's gid
33         # from the cred and authenticate using that
34         client_gid = Credential(string=cred).get_gid_caller()
35         client_gid_str = client_gid.save_to_string(save_parents=True)
36         self.api.auth.authenticateGid(client_gid_str, [cred, hrn], request_hash)
37         self.api.auth.check(cred, 'stopslice')
38         slices = Slices(self.api)
39         slices.stop_slice(hrn)
40         
41         return 1