RANGER-588 : Take care of Ranger KMS installation even if java is not in PATH
Signed-off-by: Velmurugan Periasamy <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/4d3192fd Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/4d3192fd Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/4d3192fd Branch: refs/heads/HDP-2.3.2-groupid Commit: 4d3192fdc7e3550b4cb087c4af98f7c97bfde879 Parents: 3770fbd Author: Gautam Borad <[email protected]> Authored: Fri Aug 7 12:19:11 2015 +0530 Committer: Velmurugan Periasamy <[email protected]> Committed: Mon Aug 31 11:07:08 2015 -0400 ---------------------------------------------------------------------- kms/scripts/db_setup.py | 23 +---------------------- kms/scripts/dba_script.py | 26 ++------------------------ 2 files changed, 3 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4d3192fd/kms/scripts/db_setup.py ---------------------------------------------------------------------- diff --git a/kms/scripts/db_setup.py b/kms/scripts/db_setup.py old mode 100644 new mode 100755 index 61940cc..5e2f950 --- a/kms/scripts/db_setup.py +++ b/kms/scripts/db_setup.py @@ -72,31 +72,10 @@ def populate_global_dict(): key , value = each_line.strip().split("=",1) key = key.strip() if 'PASSWORD' in key: - jceks_file_path = os.path.join(RANGER_KMS_HOME, 'jceks','ranger_db.jceks') - statuscode,value = call_keystore(library_path,key,'',jceks_file_path,'get') - if statuscode == 1: - value = '' + value = '' value = value.strip() globalDict[key] = value -def call_keystore(libpath,aliasKey,aliasValue , filepath,getorcreate): - finalLibPath = libpath.replace('\\','/').replace('//','/') - finalFilePath = 'jceks://file/'+filepath.replace('\\','/').replace('//','/') - if getorcreate == 'create': - commandtorun = ['java', '-cp', finalLibPath, 'org.apache.ranger.credentialapi.buildks' ,'create', aliasKey, '-value', aliasValue, '-provider',finalFilePath] - p = Popen(commandtorun,stdin=PIPE, stdout=PIPE, stderr=PIPE) - output, error = p.communicate() - statuscode = p.returncode - return statuscode - elif getorcreate == 'get': - commandtorun = ['java', '-cp', finalLibPath, 'org.apache.ranger.credentialapi.buildks' ,'get', aliasKey, '-provider',finalFilePath] - p = Popen(commandtorun,stdin=PIPE, stdout=PIPE, stderr=PIPE) - output, error = p.communicate() - statuscode = p.returncode - return statuscode, output - else: - print 'proper command not received for input need get or create' - class BaseDB(object): def check_connection(self, db_name, db_user, db_password): http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/4d3192fd/kms/scripts/dba_script.py ---------------------------------------------------------------------- diff --git a/kms/scripts/dba_script.py b/kms/scripts/dba_script.py old mode 100644 new mode 100755 index 03e0a19..b2aa80a --- a/kms/scripts/dba_script.py +++ b/kms/scripts/dba_script.py @@ -37,25 +37,6 @@ if os_name == "LINUX": elif os_name == "WINDOWS": RANGER_KMS_HOME = os.getenv("RANGER_KMS_HOME") -def call_keystore(libpath,aliasKey,aliasValue , filepath,getorcreate): - finalLibPath = libpath.replace('\\','/').replace('//','/') - finalFilePath = 'jceks://file/'+filepath.replace('\\','/').replace('//','/') - if getorcreate == 'create': - commandtorun = ['java', '-cp', finalLibPath, 'org.apache.ranger.credentialapi.buildks' ,'create', aliasKey, '-value', aliasValue, '-provider',finalFilePath] - p = Popen(commandtorun,stdin=PIPE, stdout=PIPE, stderr=PIPE) - output, error = p.communicate() - statuscode = p.returncode - return statuscode - elif getorcreate == 'get': - commandtorun = ['java', '-cp', finalLibPath, 'org.apache.ranger.credentialapi.buildks' ,'get', aliasKey, '-provider',finalFilePath] - p = Popen(commandtorun,stdin=PIPE, stdout=PIPE, stderr=PIPE) - output, error = p.communicate() - statuscode = p.returncode - return statuscode, output - else: - print 'proper command not received for input need get or create' - - def check_output(query): if os_name == "LINUX": p = subprocess.Popen(shlex.split(query), stdout=subprocess.PIPE) @@ -83,17 +64,14 @@ def populate_global_dict(): elif os_name == "WINDOWS": read_config_file = open(os.path.join(RANGER_KMS_HOME,'bin','install_config.properties')) library_path = os.path.join(RANGER_KMS_HOME,"cred","lib","*") - read_config_file = open(os.path.join(RANGER_KMS_HOME,'install.properties')) + read_config_file = open(os.path.join(RANGER_KMS_HOME,'install.properties')) for each_line in read_config_file.read().split('\n') : if len(each_line) == 0 : continue if re.search('=', each_line): key , value = each_line.strip().split("=",1) key = key.strip() if 'PASSWORD' in key: - jceks_file_path = os.path.join(RANGER_KMS_HOME, 'jceks','ranger_db.jceks') - statuscode,value = call_keystore(library_path,key,'',jceks_file_path,'get') - if statuscode == 1: - value = '' + value = '' value = value.strip() globalDict[key] = value
