def ssh_exec(ssh, cmd, timeout=None, check_retcode=True, get_pty=False):
LOG.debug(u"{}Calling SSH: '{}'{}".format(Style.DIM, cmd, Style.RESET_ALL))
try:
_, out, err = ssh.exec_command(cmd, timeout=timeout, get_pty=get_pty)
ret_code = out.channel.recv_exit_status()
out, err = out.read().strip(), err.read().strip()
except Exception:
LOG.debug("Something went wrong in 'ssh_exec':\n{}".format(
format_exception(sys.exc_info())
))
raise
_proceed_exec_result(out, err, ret_code, check_retcode)
return ret_code, out, err
评论列表
文章目录