From 304f09a743ed409534fc27e1bff84d72435b9070 Mon Sep 17 00:00:00 2001 From: John Cheng Date: Sun, 19 Aug 2018 22:10:25 +0800 Subject: [PATCH] [AIRFLOW-2245] Add remote_host of SSH/SFTP operator as templated field (#3765) It allows remote_host to be passed to operator with XCOM. --- airflow/contrib/operators/sftp_operator.py | 4 ++-- airflow/contrib/operators/ssh_operator.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/airflow/contrib/operators/sftp_operator.py b/airflow/contrib/operators/sftp_operator.py index def54c3fbadc9..3c736c8b95101 100644 --- a/airflow/contrib/operators/sftp_operator.py +++ b/airflow/contrib/operators/sftp_operator.py @@ -37,7 +37,7 @@ class SFTPOperator(BaseOperator): :type ssh_hook: :class:`SSHHook` :param ssh_conn_id: connection id from airflow Connections :type ssh_conn_id: str - :param remote_host: remote host to connect + :param remote_host: remote host to connect (templated) :type remote_host: str :param local_filepath: local file path to get or put. (templated) :type local_filepath: str @@ -48,7 +48,7 @@ class SFTPOperator(BaseOperator): :param confirm: specify if the SFTP operation should be confirmed, defaults to True :type confirm: bool """ - template_fields = ('local_filepath', 'remote_filepath') + template_fields = ('local_filepath', 'remote_filepath', 'remote_host') @apply_defaults def __init__(self, diff --git a/airflow/contrib/operators/ssh_operator.py b/airflow/contrib/operators/ssh_operator.py index 747ad04ff0dad..c0e8953d2c344 100644 --- a/airflow/contrib/operators/ssh_operator.py +++ b/airflow/contrib/operators/ssh_operator.py @@ -35,7 +35,7 @@ class SSHOperator(BaseOperator): :type ssh_hook: :class:`SSHHook` :param ssh_conn_id: connection id from airflow Connections :type ssh_conn_id: str - :param remote_host: remote host to connect + :param remote_host: remote host to connect (templated) :type remote_host: str :param command: command to execute on remote host. (templated) :type command: str @@ -45,7 +45,7 @@ class SSHOperator(BaseOperator): :type do_xcom_push: bool """ - template_fields = ('command',) + template_fields = ('command', 'remote_host') template_ext = ('.sh',) @apply_defaults