airflow.providers.microsoft.winrm.operators.winrm

WinRMOperator

WinRMOperator 用于使用 winrm_hook 在给定的远程主机上执行命令。

模块内容

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', timeout=10, expected_return_code=0, **kwargs)[source]

基类: airflow.models.BaseOperator

WinRMOperator 用于使用 winrm_hook 在给定的远程主机上执行命令。

参数:
  • winrm_hook (airflow.providers.microsoft.winrm.hooks.winrm.WinRMHook | None) – 预定义的 ssh_hook,用于远程执行

  • ssh_conn_id (str | None) – Airflow 连接中定义的连接 ID

  • remote_host (str | None) – 要连接的远程主机

  • command (str | None) – 要在远程主机上执行的命令。(支持模板)

  • ps_path (str | None) – powershell 的路径,v5.1- 使用 powershell,v6+ 使用 pwsh。如果指定,它将作为 powershell 脚本执行命令。

  • output_encoding (str) – 用于解码 stdout 和 stderr 的编码

  • timeout (int) – 执行命令的超时时间。

  • expected_return_code (int | list[int] | range) – 命令的预期返回码值。

template_fields: collections.abc.Sequence[str] = ('command',)[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]
timeout = 10[source]
expected_return_code = 0[source]
execute(context)[source]

创建 operator 时派生。

Context 是用于渲染 jinja 模板的同一个字典。

请参考 get_template_context 获取更多 context。

此条目是否有帮助?