airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@apache.org
Subject incubator-airflow git commit: [AIRFLOW-2122] Handle boolean values in sshHook
Date Sat, 24 Feb 2018 14:55:29 GMT
Repository: incubator-airflow
Updated Branches:
  refs/heads/master 5a69811bf -> af1f9bcaa


[AIRFLOW-2122] Handle boolean values in sshHook

This allows passing boolean values in the
extra field of ssh connection

Closes #3070 from sreenathkamath/AIRFLOW-2122


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/af1f9bca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/af1f9bca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/af1f9bca

Branch: refs/heads/master
Commit: af1f9bcaa808b9f1772dfd222c8d37755810275e
Parents: 5a69811
Author: Sreenath Kamath <sreenaths1923@gmail.com>
Authored: Sat Feb 24 15:55:22 2018 +0100
Committer: Fokko Driesprong <fokkodriesprong@godatadriven.com>
Committed: Sat Feb 24 15:55:22 2018 +0100

----------------------------------------------------------------------
 airflow/contrib/hooks/ssh_hook.py    |  5 +++--
 tests/contrib/hooks/test_ssh_hook.py | 19 +++++++++++++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/af1f9bca/airflow/contrib/hooks/ssh_hook.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/hooks/ssh_hook.py b/airflow/contrib/hooks/ssh_hook.py
index 4b60405..9cf3b8b 100755
--- a/airflow/contrib/hooks/ssh_hook.py
+++ b/airflow/contrib/hooks/ssh_hook.py
@@ -91,10 +91,11 @@ class SSHHook(BaseHook, LoggingMixin):
                         self.timeout = int(extra_options["timeout"], 10)
 
                     if "compress" in extra_options \
-                            and extra_options["compress"].lower() == 'false':
+                            and str(extra_options["compress"]).lower() == 'false':
                         self.compress = False
                     if "no_host_key_check" in extra_options \
-                            and extra_options["no_host_key_check"].lower() == 'false':
+                            and \
+                            str(extra_options["no_host_key_check"]).lower() == 'false':
                         self.no_host_key_check = False
 
             if not self.remote_host:

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/af1f9bca/tests/contrib/hooks/test_ssh_hook.py
----------------------------------------------------------------------
diff --git a/tests/contrib/hooks/test_ssh_hook.py b/tests/contrib/hooks/test_ssh_hook.py
index 6f35431..0ba7b98 100644
--- a/tests/contrib/hooks/test_ssh_hook.py
+++ b/tests/contrib/hooks/test_ssh_hook.py
@@ -14,7 +14,8 @@
 
 import unittest
 from airflow import configuration
-
+from airflow.utils import db
+from airflow import models
 
 HELLO_SERVER_CMD = """
 import socket, sys
@@ -55,7 +56,7 @@ class SSHHookTest(unittest.TestCase):
             print("Connecting to server via tunnel")
             s = socket.socket()
             s.connect(("localhost", 2135))
-            print("Receiving...", )
+            print("Receiving...",)
             response = s.recv(5)
             self.assertEqual(response, b"hello")
             print("Closing connection")
@@ -65,6 +66,20 @@ class SSHHookTest(unittest.TestCase):
             self.assertEqual(self.server_handle.returncode, 0)
             print("Closing tunnel")
 
+    def test_conn_with_extra_parameters(self):
+        from airflow.contrib.hooks.ssh_hook import SSHHook
+        db.merge_conn(
+            models.Connection(conn_id='ssh_with_extra',
+                              host='localhost',
+                              conn_type='ssh',
+                              extra='{"compress" : true, "no_host_key_check" : "true"}'
+                              )
+        )
+        ssh_hook = SSHHook(ssh_conn_id='ssh_with_extra', keepalive_interval=10)
+        ssh_hook.get_conn()
+        self.assertEqual(ssh_hook.compress, True)
+        self.assertEqual(ssh_hook.no_host_key_check, True)
+
 
 if __name__ == '__main__':
     unittest.main()


Mime
View raw message