Commit a7babc72 authored by Simon Redman's avatar Simon Redman

Publicize unchecked version of command runner

parent 0dade487
......@@ -142,9 +142,13 @@ def run_command_on_host(session, command):
session.sendline(command)
def _run_commands_on_many_hosts(sessions: List[pxssh.pxssh], commands: List[str]) -> List[str]:
def unchecked_run_commands_on_many_hosts(sessions: List[pxssh.pxssh], commands: List[str]) -> List[str]:
"""
Run one command on each host in the network without error checking
:param sessions: list of logged-in pxssh sessions to run commands on
:param commands: list of commands to run, one per host
:return: output from running each command, in the same order as the sessions were presented
"""
outputs = []
num_hosts = len(sessions)
......@@ -171,10 +175,10 @@ def run_commands_on_many_hosts(sessions: List[pxssh.pxssh], commands: List[str])
:param sessions: list of logged-in pxssh sessions to run commands on
:param commands: list of commands to run, one per host
:return: exit code and output from running each command, in the same order as the sessions were presented
:return: output from running each command, in the same order as the sessions were presented
"""
outputs = _run_commands_on_many_hosts(sessions, commands)
outputs = unchecked_run_commands_on_many_hosts(sessions, commands)
codes = get_exit_codes(sessions)
# Check for any error-indicating exit codes
......@@ -197,7 +201,7 @@ def get_exit_codes(sessions) -> List[int]:
"""
commands = ["echo $?" for session in sessions]
outputs = _run_commands_on_many_hosts(sessions, commands)
outputs = unchecked_run_commands_on_many_hosts(sessions, commands)
codes_strs = [code.split()[2] for code in outputs] # Get just the return code (not the echo'ed command)
codes = [int(code) for code in codes_strs]
return codes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment