summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Szabo <oleewere@gmail.com>2018-06-01 16:39:51 +0200
committerOliver Szabo <oleewere@gmail.com>2018-06-01 16:39:51 +0200
commit7b40c1c38c395d4048dd6e7ec967d72c0e86fe8b (patch)
treebf551d22786f0ebf1fa4b9fb7b4324e6a0b60288
parentb79e4be51bdf8067958e17998f4e61c92ed98556 (diff)
AMBARI-23945. Fix migration scripts if ambari-server uses HTTPS.
-rwxr-xr-xambari-infra/ambari-infra-solr-client/src/main/python/migrationConfigGenerator.py13
-rwxr-xr-xambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py11
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 9cb5ea47a8..75499f2f8d 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 3c811d4d86..7866ed3bd6 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))