initial checkin
authorTony Mack <tmack@cs.princeton.edu>
Mon, 9 Nov 2009 02:00:44 +0000 (02:00 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Mon, 9 Nov 2009 02:00:44 +0000 (02:00 +0000)
sfacomponent/methods/reboot.py [new file with mode: 0644]

diff --git a/sfacomponent/methods/reboot.py b/sfacomponent/methods/reboot.py
new file mode 100644 (file)
index 0000000..1ad6f47
--- /dev/null
@@ -0,0 +1,30 @@
+### $Id: reboot.py 15428 2009-10-23 15:28:03Z tmack $
+### $URL: https://svn.planet-lab.org/svn/sfa/trunk/sfa/methods/reboot.py $
+import os
+from sfa.util.faults import *
+from sfa.util.misc import *
+from sfa.util.method import Method
+from sfa.util.parameter import Parameter, Mixed
+
+class reboot(Method):
+    """
+    Reboot the component       
+
+    @param cred credential string specifying the rights of the caller
+    @return None  
+    """
+
+    interfaces = ['component']
+    
+    accepts = [
+        Parameter(str, "Credential string"),
+        ]
+
+    returns = None
+    
+    def call(self, cred, request_hash=None):
+        client_gid = Credential(string=cred).get_gid_caller()
+        client_gid_str = client_gid.save_to_string(save_parents=True)
+        self.api.auth.authenticateGid(client_gid_str, [cred], request_hash)
+        self.api.auth.check(cred, 'reboot')
+        os.system("/sbin/reboot")