method name is get_key not request_key. use commands instead of os.system
authorTony Mack <tmack@cs.princeton.edu>
Mon, 7 Dec 2009 22:55:17 +0000 (22:55 +0000)
committerTony Mack <tmack@cs.princeton.edu>
Mon, 7 Dec 2009 22:55:17 +0000 (22:55 +0000)
sfa/methods/get_key.py

index 6e84d32..8f2c2f2 100644 (file)
@@ -2,13 +2,14 @@
 ### $URL:  $
 import os
 import tempfile
+import commands
 from sfa.util.faults import *
 from sfa.util.misc import *
 from sfa.util.method import Method
 from sfa.util.parameter import Parameter, Mixed
 from sfa.trust.auth import Auth
 
-class request_key(Method):
+class get_key(Method):
     """
     Generate a new keypair and gid for requesting caller (component).     
     @return 1 If successful  
@@ -57,7 +58,10 @@ class request_key(Method):
         host = node['hostname']
         dest="/etc/sfa/nodekey.key" 
         identity = "/etc/planetlab/root_ssh_key.pub"
-        os.system("scp -i %(identity)s %(filename)s root@%(host)s:%(dest)s" % locals()
-        os.remove(filename)
+        scp_command = "scp -i %(identity)s %(filename)s root@%(host)s:%(dest)s" % locals()
+        (status, output) = commands(scp_command)
+        if status:
+            raise Exception, output
+        os.unlink(filename)
 
         return 1