本文整理汇总了Python中pssh.ParallelSSHClient.get_output方法的典型用法代码示例。如果您正苦于以下问题:Python ParallelSSHClient.get_output方法的具体用法?Python ParallelSSHClient.get_output怎么用?Python ParallelSSHClient.get_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pssh.ParallelSSHClient
的用法示例。
在下文中一共展示了ParallelSSHClient.get_output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pssh_client_run_command_get_output_explicit
# 需要导入模块: from pssh import ParallelSSHClient [as 别名]
# 或者: from pssh.ParallelSSHClient import get_output [as 别名]
def test_pssh_client_run_command_get_output_explicit(self):
client = ParallelSSHClient([self.host], port=self.listen_port,
pkey=self.user_key)
out = client.run_command(self.fake_cmd)
cmds = [cmd for host in out for cmd in [out[host]['cmd']]]
output = {}
for cmd in cmds:
client.get_output(cmd, output)
expected_exit_code = 0
expected_stdout = [self.fake_resp]
expected_stderr = []
stdout = list(output[self.host]['stdout'])
stderr = list(output[self.host]['stderr'])
exit_code = output[self.host]['exit_code']
self.assertEqual(expected_exit_code, exit_code,
msg="Got unexpected exit code - %s, expected %s" %
(exit_code,
expected_exit_code,))
self.assertEqual(expected_stdout, stdout,
msg="Got unexpected stdout - %s, expected %s" %
(stdout,
expected_stdout,))
self.assertEqual(expected_stderr, stderr,
msg="Got unexpected stderr - %s, expected %s" %
(stderr,
expected_stderr,))
del client
示例2: test_pssh_client_run_command_get_output_explicit
# 需要导入模块: from pssh import ParallelSSHClient [as 别名]
# 或者: from pssh.ParallelSSHClient import get_output [as 别名]
def test_pssh_client_run_command_get_output_explicit(self):
server = start_server({ self.fake_cmd : self.fake_resp },
self.listen_socket)
client = ParallelSSHClient(['127.0.0.1'], port=self.listen_port,
pkey=self.user_key)
out = client.run_command(self.fake_cmd)
cmds = [cmd for host in out for cmd in [out[host]['cmd']]]
output = client.get_output(commands=cmds)
expected_exit_code = 0
expected_stdout = [self.fake_resp]
expected_stderr = []
exit_code = output['127.0.0.1']['exit_code']
stdout = list(output['127.0.0.1']['stdout'])
stderr = list(output['127.0.0.1']['stderr'])
self.assertEqual(expected_exit_code, exit_code,
msg="Got unexpected exit code - %s, expected %s" %
(exit_code,
expected_exit_code,))
self.assertEqual(expected_stdout, stdout,
msg="Got unexpected stdout - %s, expected %s" %
(stdout,
expected_stdout,))
self.assertEqual(expected_stderr, stderr,
msg="Got unexpected stderr - %s, expected %s" %
(stderr,
expected_stderr,))
del client
server.join()