updated node configuration
[tests.git] / qaapi / qa / tests / node_remote_call.py
1 #!/usr/bin/python
2 import os, sys
3 from Test import Test
4 from qa import utils
5
6 class node_remote_call(Test):
7     """
8     Attempt to connect to a node using the plc root key and
9     issue a command.
10     """
11
12     def call(self, hostname, command, root_key_path = "/etc/planetlab/root_ssh_key.rsa"):
13         if not os.path.isfile(root_key_path):
14             raise Exception, "no such private key file %(root_key_path)s" % locals()
15          
16         full_command = "ssh -i %(root_key_path)s root@%(hostname)s %(command)s" % locals()
17         if self.config.verbose:
18             utils.header(full_command)
19         (stdout, stderr) = utils.popen(full_command)
20         
21         if self.config.verbose:
22             utils.header("\n".join(stdout))
23
24
25         return 1 
26
27 if  __name__ == '__main__':
28     args = tuple(sys.argv[1:])
29     plc_remote_call()(*args)