airflow.providers.microsoft.winrm.operators.winrm

Classes

WinRMOperator

WinRMOperator to execute commands on given remote host using the winrm_hook.

Module Contents

class airflow.providers.microsoft.winrm.operators.winrm.WinRMOperator(*, winrm_hook=None, ssh_conn_id=None, remote_host=None, command=None, ps_path=None, output_encoding='utf-8', max_output_chunks=100, timeout=None, poll_interval=None, expected_return_code=0, working_directory=None, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

Bases: airflow.providers.common.compat.sdk.BaseOperator

WinRMOperator to execute commands on given remote host using the winrm_hook.

Parameters:
  • winrm_hook (airflow.providers.microsoft.winrm.hooks.winrm.WinRMHook | None) – predefined ssh_hook to use for remote execution

  • ssh_conn_id (str | None) – connection id from airflow Connections

  • remote_host (str | None) – remote host to connect

  • command (str | None) – command to execute on remote host. (templated)

  • ps_path (str | None) – path to powershell, powershell for v5.1- and pwsh for v6+. If specified, it will execute the command as powershell script.

  • output_encoding (str) – the encoding used to decode stout and stderr

  • max_output_chunks (int) – Maximum number of stdout/stderr chunks to keep in a rolling buffer to prevent excessive memory usage for long-running commands in deferrable mode, defaults to 100.

  • timeout (int | datetime.timedelta | None) – timeout for executing the command, defaults to 10.

  • poll_interval (int | datetime.timedelta | None) – How often, in seconds, the trigger should poll the output command of the launched command, defaults to 1.

  • expected_return_code (int | list[int] | range) – expected return code value(s) of command.

  • working_directory (str | None) – specify working directory.

  • deferrable (bool) – Run operator in the deferrable mode

template_fields: collections.abc.Sequence[str] = ('command', 'working_directory')[source]
template_fields_renderers[source]
winrm_hook = None[source]
ssh_conn_id = None[source]
remote_host = None[source]
command = None[source]
ps_path = None[source]
output_encoding = 'utf-8'[source]
max_output_chunks = 100[source]
poll_interval[source]
expected_return_code = 0[source]
working_directory = None[source]
deferrable[source]
property hook: airflow.providers.microsoft.winrm.hooks.winrm.WinRMHook[source]
execute(context)[source]

Derive when creating an operator.

The main method to execute the task. Context is the same dictionary used as when rendering jinja templates.

Refer to get_template_context for more context.

validate_return_code(return_code)[source]
evaluate_result(return_code, stdout_buffer, stderr_buffer)[source]
execute_complete(context, event)[source]

Execute callback when WinRMCommandOutputTrigger finishes execution.

This method gets executed automatically when WinRMCommandOutputTrigger completes its execution.

Was this entry helpful?