diff --git a/bin/phoenix_utils.py b/bin/phoenix_utils.py index 27032df5f13..103bd70c8d7 100755 --- a/bin/phoenix_utils.py +++ b/bin/phoenix_utils.py @@ -25,6 +25,9 @@ import re import subprocess import sys +import xml.etree.ElementTree as ET + +zk_tls_args = "" def find(pattern, classPaths): paths = classPaths.split(os.pathsep) @@ -126,6 +129,28 @@ def setPath(): # Try to provide something valid hbase_conf_dir = '.' + hbase_site_file = os.path.join(hbase_conf_dir, "hbase-site.xml") + try: + global zk_tls_args + root = ET.parse(hbase_site_file).getroot() + zk_hbase_prefix = "hbase.zookeeper.property." + zkcfg = { + prop.find("name").text[len(zk_hbase_prefix):]: prop.find("value").text + for prop in root.findall("property") + if prop.find("name").text.startswith(zk_hbase_prefix) + } + if 'client.secure' in zkcfg and zkcfg.get('client.secure').lower() == 'true': + zk_tls_args = '-Dzookeeper.client.secure=true ' + \ + '-Dzookeeper.clientCnxnSocket=' + zkcfg['clientCnxnSocket'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.location=' + zkcfg['ssl.trustStore.location'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.type=' + zkcfg['ssl.trustStore.type'] + ' ' + \ + '-Dzookeeper.ssl.trustStore.password=' + zkcfg['ssl.trustStore.password'] + ' ' + except Exception as e: + sys.exit( + "ERROR: Failed to parse ZooKeeper TLS properties from '%s': %s" + % (hbase_site_file, repr(e)) + ) + global current_dir current_dir = os.path.dirname(os.path.abspath(__file__)) @@ -316,6 +341,7 @@ def common_sqlline_args(parser): setPath() print("phoenix_class_path:", phoenix_class_path) print("hbase_conf_dir:", hbase_conf_dir) + print("zk_tls_args:", zk_tls_args) print("current_dir:", current_dir) print("phoenix_embedded_jar_path:", phoenix_embedded_jar_path) print("phoenix_client_embedded_jar:", phoenix_client_embedded_jar) diff --git a/bin/sqlline.py b/bin/sqlline.py index 09424789de4..7fc8d252c6e 100755 --- a/bin/sqlline.py +++ b/bin/sqlline.py @@ -94,6 +94,7 @@ def kill_child(): java_cmd = phoenix_utils.java + ' ' + phoenix_utils.jvm_module_flags + \ ' ' + opts + \ + ' ' + phoenix_utils.zk_tls_args + \ ' -cp "' + phoenix_utils.hbase_conf_dir + os.pathsep + \ phoenix_utils.hadoop_conf + os.pathsep + \ phoenix_utils.sqlline_with_deps_jar + os.pathsep + \