Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: changed psql parser in 
engine-upgrade.getCompensations
......................................................................

packaging: changed psql parser in engine-upgrade.getCompensations

Better solution for compensation query parsing.

Change-Id: Ic46bf04a0263a25961016804acd26e4f5af19c2d
Bug-Url: https://bugzilla.redhat.com/912426
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M packaging/fedora/setup/engine-upgrade.py
1 file changed, 22 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/13162/1

diff --git a/packaging/fedora/setup/engine-upgrade.py 
b/packaging/fedora/setup/engine-upgrade.py
index 53346ca..687588d 100755
--- a/packaging/fedora/setup/engine-upgrade.py
+++ b/packaging/fedora/setup/engine-upgrade.py
@@ -41,6 +41,7 @@
 # ASYNC TASKS AND COMPLETIONS QUERIES
 ASYNC_TASKS_QUERY = "select * from fn_db_get_async_tasks();"
 COMPENSATIONS_QUERY = "select command_type, entity_type from 
business_entity_snapshot;"
+COMPENSATIONS_COUNT_QUERY = "select COUNT(*) from business_entity_snapshot;"
 
 ETL_SERVICE="/etc/init.d/ovirt-engine-etl"
 
@@ -871,23 +872,28 @@
     Get compensations.
     Returns an empty string if there are no compensations.
     """
-    compensations, rc = utils.execRemoteSqlCommand(
-                                       userName=SERVER_ADMIN,
-                                       dbHost=SERVER_NAME,
-                                       dbPort=SERVER_PORT,
-                                       dbName=dbName,
-                                       sqlQuery=COMPENSATIONS_QUERY,
-                                       failOnError=True,
-                                       errMsg="Can't get compensations list",
-                                    )
-
-    # We only want to return anything if there are really compensations records
-    if not compensations or \
-       (compensations and len(compensations.split("\n")) <= 5):
-        # An empty set has 5 rows: column names, -+- , "0 rows", 2 empty lines
-        return ""
-    else:
+    compensations, rc = utils.parseRemoteSqlCommand(
+        userName=SERVER_ADMIN,
+        dbHost=SERVER_NAME,
+        dbPort=SERVER_PORT,
+        dbName=dbName,
+        sqlQuery=COMPENSATIONS_COUNT_QUERY,
+        failOnError=True,
+        errMsg="Can't get compensations list",
+    )
+    if compensations and int(compensations[0]['count']) > 0:
+        compensations, rc = utils.execRemoteSqlCommand(
+            userName=SERVER_ADMIN,
+            dbHost=SERVER_NAME,
+            dbPort=SERVER_PORT,
+            dbName=dbName,
+            sqlQuery=COMPENSATIONS_QUERY,
+            failOnError=True,
+            errMsg="Can't get compensations list",
+        )
         return compensations
+    else:
+        return ""
 
 
 def checkRunningTasks(dbName=basedefs.DB_NAME, 
service=basedefs.ENGINE_SERVICE_NAME):


--
To view, visit http://gerrit.ovirt.org/13162
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic46bf04a0263a25961016804acd26e4f5af19c2d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to