|
|
|
@ -391,8 +391,6 @@ class Connection(ConnectionBase):
|
|
|
|
|
stdin_push_failed = False
|
|
|
|
|
command_id = self.protocol.run_command(self.shell_id, to_bytes(command), map(to_bytes, args), console_mode_stdin=(stdin_iterator is None))
|
|
|
|
|
|
|
|
|
|
# TODO: try/except around this, so we can get/return the command result on a broken pipe or other failure (probably more useful than the 500 that
|
|
|
|
|
# comes from this)
|
|
|
|
|
try:
|
|
|
|
|
if stdin_iterator:
|
|
|
|
|
for (data, is_last) in stdin_iterator:
|
|
|
|
@ -400,12 +398,9 @@ class Connection(ConnectionBase):
|
|
|
|
|
|
|
|
|
|
except Exception as ex:
|
|
|
|
|
from traceback import format_exc
|
|
|
|
|
display.warning("FATAL ERROR DURING FILE TRANSFER: %s" % format_exc())
|
|
|
|
|
display.warning("FATAL ERROR DURING FILE TRANSFER: %s" % to_text(ex))
|
|
|
|
|
stdin_push_failed = True
|
|
|
|
|
|
|
|
|
|
if stdin_push_failed:
|
|
|
|
|
raise AnsibleError('winrm send_input failed')
|
|
|
|
|
|
|
|
|
|
# NB: this can hang if the receiver is still running (eg, network failed a Send request but the server's still happy).
|
|
|
|
|
# FUTURE: Consider adding pywinrm status check/abort operations to see if the target is still running after a failure.
|
|
|
|
|
resptuple = self.protocol.get_command_output(self.shell_id, command_id)
|
|
|
|
@ -423,7 +418,11 @@ class Connection(ConnectionBase):
|
|
|
|
|
display.vvvvvv('WINRM STDERR %s' % to_text(response.std_err), host=self._winrm_host)
|
|
|
|
|
|
|
|
|
|
if stdin_push_failed:
|
|
|
|
|
raise AnsibleError('winrm send_input failed; \nstdout: %s\nstderr %s' % (response.std_out, response.std_err))
|
|
|
|
|
stderr = to_bytes(response.std_err, encoding='utf-8')
|
|
|
|
|
if self.is_clixml(stderr):
|
|
|
|
|
stderr = self.parse_clixml_stream(stderr)
|
|
|
|
|
|
|
|
|
|
raise AnsibleError('winrm send_input failed; \nstdout: %s\nstderr %s' % (response.std_out, stderr))
|
|
|
|
|
|
|
|
|
|
return response
|
|
|
|
|
finally:
|
|
|
|
@ -456,7 +455,9 @@ class Connection(ConnectionBase):
|
|
|
|
|
'powershell_modules': {},
|
|
|
|
|
'actions': ['exec'],
|
|
|
|
|
'exec': to_text(base64.b64encode(to_bytes(leaf_exec))),
|
|
|
|
|
'environment': environment
|
|
|
|
|
'environment': environment,
|
|
|
|
|
'min_ps_version': None,
|
|
|
|
|
'min_os_version': None
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return json.dumps(payload)
|
|
|
|
|