initial checkin of reboot and redeem_ticket methods"
[sfa.git] / sfa / methods / reboot.py
1 ### $Id: reboot.py 15428 2009-10-23 15:28:03Z tmack $
2 ### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfacomponent/methods/reboot.py $
3 import os
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 reboot(Method):
10     """
11     Reboot the component       
12
13     @param cred credential string specifying the rights of the caller
14     @return None  
15     """
16
17     interfaces = ['component']
18     
19     accepts = [
20         Parameter(str, "Credential string"),
21         ]
22
23     returns = None
24     
25     def call(self, cred, request_hash=None):
26         client_gid = Credential(string=cred).get_gid_caller()
27         client_gid_str = client_gid.save_to_string(save_parents=True)
28         self.api.auth.authenticateGid(client_gid_str, [cred], request_hash)
29         self.api.auth.check(cred, 'reboot')
30         os.system("/sbin/reboot")