You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2020/04/23 13:09:32 UTC
[ranger] branch master updated: RANGER-2803: Modify db_setup.py
script to handle pre-created user's tablespace for Oracle
This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new 6decd3a RANGER-2803: Modify db_setup.py script to handle pre-created user's tablespace for Oracle
6decd3a is described below
commit 6decd3a0ba8bff83dff0863a9694afdf47a63cd9
Author: pradeep <pr...@apache.org>
AuthorDate: Mon Apr 20 23:05:30 2020 +0530
RANGER-2803: Modify db_setup.py script to handle pre-created user's
tablespace for Oracle
---
kms/scripts/db_setup.py | 14 +++++++-------
security-admin/scripts/db_setup.py | 12 ++++++++++++
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/kms/scripts/db_setup.py b/kms/scripts/db_setup.py
index b68ff5c..7a0105e 100644
--- a/kms/scripts/db_setup.py
+++ b/kms/scripts/db_setup.py
@@ -268,21 +268,21 @@ class OracleConf(BaseDB):
output = check_output(query).strip()
output = output.strip(' |')
db_name = db_name.upper()
- if output == db_name:
- log("[I] User name " + db_user + " and tablespace " + db_name + " already exists.","info")
- log("[I] Verifying table " + TABLE_NAME +" in tablespace " + db_name, "info")
+ if ((output == db_name) or (db_name =='' and output is not None and output != '')):
+ log("[I] User name " + db_user + " and tablespace " + output + " already exists.","info")
+ log("[I] Verifying table " + TABLE_NAME +" in tablespace " + output, "info")
get_cmd = self.get_jisql_cmd(db_user, db_password)
if is_unix:
- query = get_cmd + " -c \; -query \"select UPPER(table_name) from all_tables where UPPER(tablespace_name)=UPPER('%s') and UPPER(table_name)=UPPER('%s');\"" %(db_name ,TABLE_NAME)
+ query = get_cmd + " -c \; -query \"select UPPER(table_name) from all_tables where UPPER(tablespace_name)=UPPER('%s') and UPPER(table_name)=UPPER('%s');\"" %(output ,TABLE_NAME)
elif os_name == "WINDOWS":
- query = get_cmd + " -query \"select UPPER(table_name) from all_tables where UPPER(tablespace_name)=UPPER('%s') and UPPER(table_name)=UPPER('%s');\" -c ;" %(db_name ,TABLE_NAME)
+ query = get_cmd + " -query \"select UPPER(table_name) from all_tables where UPPER(tablespace_name)=UPPER('%s') and UPPER(table_name)=UPPER('%s');\" -c ;" %(output ,TABLE_NAME)
jisql_log(query, db_password)
output = check_output(query)
if output.strip(TABLE_NAME.upper() + ' |'):
- log("[I] Table " + TABLE_NAME +" already exists in tablespace " + db_name + "","info")
+ log("[I] Table " + TABLE_NAME +" already exists in tablespace " + output + "","info")
return True
else:
- log("[I] Table " + TABLE_NAME +" does not exist in tablespace " + db_name + "","info")
+ log("[I] Table " + TABLE_NAME +" does not exist in tablespace " + output + "","info")
return False
else:
log("[E] "+db_user + " user already assigned to some other tablespace , provide different DB name.","error")
diff --git a/security-admin/scripts/db_setup.py b/security-admin/scripts/db_setup.py
index e16d15e..6670e6c 100644
--- a/security-admin/scripts/db_setup.py
+++ b/security-admin/scripts/db_setup.py
@@ -808,7 +808,19 @@ class OracleConf(BaseDB):
return ret
def get_check_table_query(self, TABLE_NAME):
+ CT=self.commandTerminator
+ get_cmd = self.get_jisql_cmd(self.db_user, self.db_password, self.db_name)
+ if is_unix:
+ query = get_cmd + CT + " -query 'select default_tablespace from user_users;'"
+ elif os_name == "WINDOWS":
+ query = get_cmd + " -query \"select default_tablespace from user_users;\" -c ;"
+ jisql_log(query, self.db_password)
+ output = check_output(query).strip()
+ output = output.strip(' |')
db_name=self.db_name.upper()
+ if (db_name =='' and output is not None and output != ''):
+ db_name = output
+ #db_name could be given db_name or user's default tablespace name
return "select UPPER(table_name) from all_tables where UPPER(tablespace_name)=UPPER('%s') and UPPER(table_name)=UPPER('%s');" %(db_name ,TABLE_NAME)
def get_unstale_patch_query(self, version, isActive, client_host,stalePatchEntryHoldTimeInMinutes):