You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2018/10/11 05:59:31 UTC

[ambari] branch trunk updated: AMBARI-24757. Grafana start failing on U14 fails with error "AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'" (aonishuk)

This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 2415a03  AMBARI-24757. Grafana start failing on U14 fails with error "AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'" (aonishuk)
2415a03 is described below

commit 2415a03b24dab92e703f71e7bca0a502a66bb402
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Wed Oct 10 10:46:54 2018 +0300

    AMBARI-24757. Grafana start failing on U14 fails with error "AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'" (aonishuk)
---
 ambari-agent/src/main/python/ambari_agent/AmbariConfig.py            | 5 +++--
 .../src/main/python/resource_management/libraries/script/script.py   | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py b/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
index 0d80dd0..fedd063 100644
--- a/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
+++ b/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
@@ -24,6 +24,7 @@ import StringIO
 import hostname
 import ambari_simplejson as json
 import os
+import ssl
 
 from ambari_agent.FileCache import FileCache
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@@ -376,7 +377,8 @@ class AmbariConfig:
 
     :return: protocol name, PROTOCOL_TLSv1_2 by default
     """
-    return self.get('security', 'force_https_protocol', default="PROTOCOL_TLSv1_2")
+    default = "PROTOCOL_TLSv1_2" if hasattr(ssl, "PROTOCOL_TLSv1_2") else "PROTOCOL_TLSv1"
+    return self.get('security', 'force_https_protocol', default=default)
 
   def get_force_https_protocol_value(self):
     """
@@ -384,7 +386,6 @@ class AmbariConfig:
 
     :return: protocol value
     """
-    import ssl
     return getattr(ssl, self.get_force_https_protocol_name())
 
   def get_ca_cert_file_path(self):
diff --git a/ambari-common/src/main/python/resource_management/libraries/script/script.py b/ambari-common/src/main/python/resource_management/libraries/script/script.py
index a792271..9b47f0e 100644
--- a/ambari-common/src/main/python/resource_management/libraries/script/script.py
+++ b/ambari-common/src/main/python/resource_management/libraries/script/script.py
@@ -24,6 +24,7 @@ __all__ = ["Script"]
 import re
 import os
 import sys
+import ssl
 import logging
 import platform
 import inspect
@@ -134,7 +135,7 @@ class Script(object):
 
   # Class variable
   tmp_dir = ""
-  force_https_protocol = "PROTOCOL_TLSv1_2"
+  force_https_protocol = "PROTOCOL_TLSv1_2" if hasattr(ssl, "PROTOCOL_TLSv1_2") else "PROTOCOL_TLSv1"
   ca_cert_file_path = None
 
   def load_structured_out(self):
@@ -663,7 +664,6 @@ class Script(object):
 
     :return: protocol value
     """
-    import ssl
     return getattr(ssl, Script.get_force_https_protocol_name())
 
   @staticmethod