ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-17770 HDFS Service Check failure on Wireencrypted clusters with Ambari2400+HDP2.4.2.0 (dsen)
Date Mon, 18 Jul 2016 15:54:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 a0fac264d -> eed73ae35


AMBARI-17770 HDFS Service Check failure on Wireencrypted clusters with Ambari2400+HDP2.4.2.0
(dsen)


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

Branch: refs/heads/branch-2.4
Commit: eed73ae35c9b58b09601388abd6d7b77ae70e938
Parents: a0fac26
Author: Dmytro Sen <dsen@apache.org>
Authored: Mon Jul 18 18:53:22 2016 +0300
Committer: Dmytro Sen <dsen@apache.org>
Committed: Mon Jul 18 18:54:29 2016 +0300

----------------------------------------------------------------------
 .../HDFS/2.1.0.2.0/package/files/checkWebUI.py  | 45 ++++++++++++++++----
 1 file changed, 37 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eed73ae3/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/files/checkWebUI.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/files/checkWebUI.py
b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/files/checkWebUI.py
index aa60ffc..ddeb116 100644
--- a/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/files/checkWebUI.py
+++ b/ambari-server/src/main/resources/common-services/HDFS/2.1.0.2.0/package/files/checkWebUI.py
@@ -20,7 +20,43 @@ limitations under the License.
 
 import optparse
 import httplib
+import socket
+import ssl
 
+class TLS1HTTPSConnection(httplib.HTTPSConnection):
+  """
+  Some of python implementations does not work correctly with sslv3 but trying to use it,
we need to change protocol to
+  tls1.
+  """
+  def __init__(self, host, port, **kwargs):
+    httplib.HTTPSConnection.__init__(self, host, port, **kwargs)
+
+  def connect(self):
+    sock = socket.create_connection((self.host, self.port), self.timeout)
+    if getattr(self, '_tunnel_host', None):
+      self.sock = sock
+      self._tunnel()
+    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_TLSv1)
+
+def make_connection(host, port, https):
+  try:
+    conn = httplib.HTTPConnection(host, port) if not https else httplib.HTTPSConnection(host,
port)
+    conn.request("GET", "/")
+    return conn.getresponse().status
+  except ssl.SSLError:
+    # got ssl error, lets try to use TLS1 protocol, maybe it will work
+    try:
+      tls1_conn = TLS1HTTPSConnection(host, port)
+      tls1_conn.request("GET", "/")
+      return tls1_conn.getresponse().status
+    except Exception as e:
+      print e
+    finally:
+      tls1_conn.close()
+  except Exception as e:
+    print e
+  finally:
+    conn.close()
 #
 # Main.
 #
@@ -37,14 +73,7 @@ def main():
   https = options.https
 
   for host in hosts:
-    try:
-      conn = httplib.HTTPConnection(host, port) if not https.lower() == "true" else httplib.HTTPSConnection(host,
port)
-      # This can be modified to get a partial url part to be sent with request
-      conn.request("GET", "/")
-      httpCode = conn.getresponse().status
-      conn.close()
-    except Exception:
-      httpCode = 404
+    httpCode = make_connection(host, port, https.lower() == "true")
 
     if httpCode != 200:
       print "Cannot access WEB UI on: http://" + host + ":" + port if not https.lower() ==
"true" else "Cannot access WEB UI on: https://" + host + ":" + port


Mime
View raw message