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 2017/03/08 04:42:28 UTC

ranger git commit: RANGER-1423 : Ranger Upgrade is failing for Oracle DB flavor

Repository: ranger
Updated Branches:
  refs/heads/ranger-0.6 f3cee6d92 -> 9561f0d5b


RANGER-1423 : Ranger Upgrade is failing for Oracle DB flavor


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/9561f0d5
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/9561f0d5
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/9561f0d5

Branch: refs/heads/ranger-0.6
Commit: 9561f0d5b31f2bf48147df2171b0dceff8f5000c
Parents: f3cee6d
Author: pradeep <pr...@apache.org>
Authored: Mon Mar 6 12:47:26 2017 +0530
Committer: pradeep <pr...@apache.org>
Committed: Wed Mar 8 10:11:39 2017 +0530

----------------------------------------------------------------------
 security-admin/scripts/db_setup.py | 43 ++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/9561f0d5/security-admin/scripts/db_setup.py
----------------------------------------------------------------------
diff --git a/security-admin/scripts/db_setup.py b/security-admin/scripts/db_setup.py
index c1efd4a..c104ecb 100644
--- a/security-admin/scripts/db_setup.py
+++ b/security-admin/scripts/db_setup.py
@@ -1126,17 +1126,38 @@ class OracleConf(BaseDB):
 						log("[I] java patch "+ className  +" is already applied" ,"info")
 					else:
 						if os_name == "LINUX":
-							query = get_cmd + " -c \; -query \"select version from x_db_version_h where version = 'J%s' and active = 'Y';\"" %(version)
+							query = get_cmd + " -c \; -query \"select version from x_db_version_h where version = 'J%s' and active = 'N';\"" %(version)
 						elif os_name == "WINDOWS":
-							query = get_cmd + " -query \"select version from x_db_version_h where version = 'J%s' and active = 'Y';\" -c ;" %(version)
+							query = get_cmd + " -query \"select version from x_db_version_h where version = 'J%s' and active = 'N';\" -c ;" %(version)
 						jisql_log(query, db_password)
 						output = check_output(query)
-						if output.strip(version + " |"):
-							while(output.strip(version + " |")):
-								log("[I] Java patch "+ className  +" is being applied by some other process" ,"info")
-								time.sleep(300)
-								jisql_log(query, db_password)
-								output = check_output(query)
+						if output.strip(version + " |"):#
+							if os_name == "LINUX":
+								queryInstallAt = get_cmd + " -c \; -query \"select version from x_db_version_h where version = 'J%s' and active = 'N' and inst_at<=CURRENT_DATE-1;\"" %(version)
+							elif os_name == "WINDOWS":
+								queryInstallAt = get_cmd + " -query \"select version from x_db_version_h where version = 'J%s' and active = 'N' inst_at<=CURRENT_DATE-1;\" -c ;" %(version)
+							jisql_log(queryInstallAt, db_password)
+							outputInstallAt = check_output(queryInstallAt)
+							if outputInstallAt.strip(version + " |"):
+								if os_name == "LINUX":
+									queryUpdate = get_cmd + " -c \; -query \"update x_db_version_h set active='Y' where version='J%s' and active='N' and updated_by='%s' and inst_at<=CURRENT_DATE-1;\"" %(version, client_host)
+									jisql_log(queryUpdate, db_password)
+									retUpdate = subprocess.call(shlex.split(queryUpdate))
+								elif os_name == "WINDOWS":
+									queryUpdate = get_cmd + " -query \"update x_db_version_h set active='Y' where version='J%s' and active='N' and updated_by='%s' and inst_at<=CURRENT_DATE-1;\" -c ;" %(version, client_host)
+									jisql_log(queryUpdate, db_password)
+									retUpdate = subprocess.call(queryUpdate)
+								if retUpdate == 0:
+									log ("[I] java patch "+ className +" status entry has been updated to continue upgrade process.","info")
+								else:
+									log("[E] java patch "+ className +" status entry update request failed, Please update/delete java patches entries having active status 'N' from x_db_version_h table and try again!", "error")
+									sys.exit(1)
+							else:
+								while(output.strip(version + " |")):
+									log("[I] Java patch "+ className  +" is being applied by some other process" ,"info")
+									time.sleep(300)
+									jisql_log(query, db_password)
+									output = check_output(query)
 						else:
 							if os_name == "LINUX":
 								query = get_cmd + " -c \; -query \"insert into x_db_version_h (id,version, inst_at, inst_by, updated_at, updated_by,active) values ( X_DB_VERSION_H_SEQ.nextval,'J%s', sysdate, '%s', sysdate, '%s','N');\"" %(version, client_host, client_host)
@@ -1155,11 +1176,11 @@ class OracleConf(BaseDB):
 								path = os.path.join("%s","WEB-INF","classes","conf:%s","WEB-INF","classes","lib","*:%s","WEB-INF",":%s","META-INF",":%s","WEB-INF","lib","*:%s","WEB-INF","classes",":%s","WEB-INF","classes","META-INF:%s" )%(app_home ,app_home ,app_home, app_home, app_home, app_home ,app_home ,self.SQL_CONNECTOR_JAR)
 							elif os_name == "WINDOWS":
 								path = os.path.join("%s","WEB-INF","classes","conf;%s","WEB-INF","classes","lib","*;%s","WEB-INF",";%s","META-INF",";%s","WEB-INF","lib","*;%s","WEB-INF","classes",";%s","WEB-INF","classes","META-INF;%s" )%(app_home ,app_home ,app_home, app_home, app_home, app_home ,app_home ,self.SQL_CONNECTOR_JAR)
-							get_cmd = "%s -Djava.security.egd=file:///dev/urandom -Dlogdir=%s -Dlog4j.configuration=db_patch.log4j.xml -cp %s org.apache.ranger.patch.%s"%(self.JAVA_BIN,ranger_log,path,className)
+							get_java_cmd = "%s -Djava.security.egd=file:///dev/urandom -Dlogdir=%s -Dlog4j.configuration=db_patch.log4j.xml -cp %s org.apache.ranger.patch.%s"%(self.JAVA_BIN,ranger_log,path,className)
 							if os_name == "LINUX":
-								ret = subprocess.call(shlex.split(get_cmd))
+								ret = subprocess.call(shlex.split(get_java_cmd))
 							elif os_name == "WINDOWS":
-								ret = subprocess.call(get_cmd)
+								ret = subprocess.call(get_java_cmd)
 							if ret == 0:
 								if os_name == "LINUX":
 									query = get_cmd + " -c \; -query \"update x_db_version_h set active='Y' where version='J%s' and active='N' and updated_by='%s';\"" %(version, client_host)