You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/06/01 14:41:31 UTC
[ambari] branch trunk updated: AMBARI-23945. Fix migration scripts
if ambari-server uses HTTPS.
This is an automated email from the ASF dual-hosted git repository.
oleewere 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 7b40c1c AMBARI-23945. Fix migration scripts if ambari-server uses HTTPS.
7b40c1c is described below
commit 7b40c1c38c395d4048dd6e7ec967d72c0e86fe8b
Author: Oliver Szabo <ol...@gmail.com>
AuthorDate: Fri Jun 1 16:39:51 2018 +0200
AMBARI-23945. Fix migration scripts if ambari-server uses HTTPS.
---
.../src/main/python/migrationConfigGenerator.py | 13 +++++++++++--
.../src/main/python/migrationHelper.py | 11 +++++++++--
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationConfigGenerator.py b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationConfigGenerator.py
index 9cb5ea4..75499f2 100755
--- a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationConfigGenerator.py
+++ b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationConfigGenerator.py
@@ -24,7 +24,7 @@ import signal
import sys
import time
import traceback
-import urllib2
+import urllib2, ssl
import logging
import json
import base64
@@ -76,7 +76,14 @@ def api_accessor(host, username, password, protocol, port):
request.add_header('X-Requested-By', 'ambari')
request.add_data(request_body)
request.get_method = lambda: request_type
- response = urllib2.urlopen(request)
+ response = None
+ if protocol == 'https':
+ ctx = ssl.create_default_context()
+ ctx.check_hostname = False
+ ctx.verify_mode = ssl.CERT_NONE
+ response = urllib2.urlopen(request, context=ctx)
+ else:
+ response = urllib2.urlopen(request)
response_body = response.read()
except Exception as exc:
raise Exception('Problem with accessing api. Reason: {0}'.format(exc))
@@ -480,6 +487,8 @@ if __name__=="__main__":
set_log_level(options.verbose)
errors = validate_inputs(options)
+ os.popen('PYTHONHTTPSVERIFY=0')
+
if errors:
print 'Errors'
for error in errors:
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
index 3c811d4..7866ed3 100755
--- a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
+++ b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
@@ -21,7 +21,7 @@ limitations under the License.
import logging
import os
import sys
-import urllib2
+import urllib2, ssl
import json
import base64
import optparse
@@ -89,7 +89,14 @@ def api_accessor(host, username, password, protocol, port):
request.add_header('X-Requested-By', 'ambari')
request.add_data(request_body)
request.get_method = lambda: request_type
- response = urllib2.urlopen(request)
+ response = None
+ if protocol == 'https':
+ ctx = ssl.create_default_context()
+ ctx.check_hostname = False
+ ctx.verify_mode = ssl.CERT_NONE
+ response = urllib2.urlopen(request, context=ctx)
+ else:
+ response = urllib2.urlopen(request)
response_body = response.read()
except Exception as exc:
raise Exception('Problem with accessing api. Reason: {0}'.format(exc))
--
To stop receiving notification emails like this one, please contact
oleewere@apache.org.