method for issuing commands on remote nodes (i.e. restarting node manager)
[tests.git] / qaapi / qa / modules / plc / remote_call.py
1 import os
2 from qa.Test import Test
3 from qa import utils
4
5 class  remote_call(Test):
6     """
7     Attempt to connect to a node using the plc root key and
8     issue a command.
9     """
10
11     def call(self, root_key_path, hostname, command):
12         if not os.path.isfile(root_key_path):
13             raise Exception, "no such private key file %(root_key_path)s" % locals()
14          
15         full_command = "ssh -i %(root_key_path)s root@%(hostname) %(command)s" % locals()
16         if self.config.verbose:
17             utils.header(full_command)
18         (stdout, stderr) = utils.popen(full_command)
19         if self.config.verbose:
20             utils.header("\n".join(stdout))
21
22
23         return 1