pyinfra.api.connectors.winrm module

pyinfra.api.connectors.winrm.connect(state, host)

Connect to a single host. Returns the winrm Session if successful.

pyinfra.api.connectors.winrm.get_file(state, host, remote_filename, filename_or_io, **command_kwargs)
pyinfra.api.connectors.winrm.make_names_data(hostname)
pyinfra.api.connectors.winrm.put_file(state, host, filename_or_io, remote_filename, **command_kwargs)
pyinfra.api.connectors.winrm.run_shell_command(state, host, command, get_pty=False, sudo=None, sudo_user=None, su_user=None, use_sudo_login=False, use_su_login=False, preserve_sudo_env=False, timeout=None, stdin=None, success_exit_codes=None, print_output=False, print_input=False, return_combined_output=False, shell_executable=None, **command_kwargs)

Execute a command on the specified host.

Parameters
  • state (pyinfra.api.State obj) – state object for this command

  • hostname (string) – hostname of the target

  • command (string) – actual command to execute

  • get_pty (boolean) – Not used for WINRM

  • sudo (boolean) – Not used for WINRM

  • sudo_user (string) – Not used for WINRM

  • use_sudo_login (boolean) – Not used for WINRM

  • use_su_login (boolean) – Not used for WINRM

  • preserve_sudo_env (boolean) – Not used for WINRM

TODO: check if winrm has a timeout and use timeout param

timeout (int): timeout for this command to complete before erroring stdin (string): Not used for WINRM success_exit_codes (list): all values in the list that will return success print_output (boolean): print the output TODO print_intput (boolean): print the input return_combined_output (boolean): combine the stdout and stderr lists shell_executable (string): shell to use - ‘sh’=cmd, ‘ps’=powershell(default) env (dict): envrionment variables to set

Returns

(exit_code, stdout, stderr) stdout and stderr are both lists of strings from each buffer.

Return type

tuple

pyinfra.api.connectors.winrm.show_warning()