ashb commented on a change in pull request #3945: [AIRFLOW-3112] Make SFTP hook 
to inherit SSH hook
URL: https://github.com/apache/incubator-airflow/pull/3945#discussion_r221428095
 
 

 ##########
 File path: airflow/contrib/hooks/sftp_hook.py
 ##########
 @@ -42,20 +42,33 @@ class SFTPHook(SSHHook):
     Errors that may occur throughout but should be handled downstream.
     """
 
-    def __init__(self, ftp_conn_id='sftp_default'):
-        super(SFTPHook, self).__init__(ftp_conn_id)
+    def __init__(self, ftp_conn_id='sftp_default', *args, **kwargs):
+        kwargs['ssh_conn_id'] = ftp_conn_id
+        super(SFTPHook, self).__init__(*args, **kwargs)
+
+        self.conn = None
 
         if self.ssh_conn_id is not None:
             conn = self.get_connection(self.ssh_conn_id)
             if conn.extra is not None:
                 extra_options = conn.extra_dejson
-                self.private_key_pass = extra_options.get('private_key_pass', 
None)
+                if 'private_key_pass' in extra_options:
+                    self.private_key_pass = 
extra_options.get('private_key_pass', None)
+
+                # For backward compatibility
+                # TODO: remove in a future version
+                if 'ignore_hostkey_verification' in extra_options \
+                        and str(extra_options["ignore_hostkey_verification"])\
+                        .lower() == 'false':
+                    self.no_host_key_check = False
+                if 'private_key' in extra_options:
 
 Review comment:
   Could you issue a DeprecationWarning here too please? See 
https://github.com/apache/incubator-airflow/blob/master/airflow/configuration.py#L403-L411
 (though you can use a literal message) - stacklevel should be `2` for this 
case so that the warning the line appears from is the caller of SFTPHook.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to