Yaniv Dary has uploaded a new change for review.

Change subject: packaging: fixed issues with setup logic
......................................................................

packaging: fixed issues with setup logic

Change-Id: I35be9a7bbf46ff99885d8ade800fcaa8706aa44f
Signed-off-by: Yaniv Dary <[email protected]>
---
M packaging/common_utils.py
M packaging/ovirt-engine-reports-setup.py
2 files changed, 18 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/08/22708/1

diff --git a/packaging/common_utils.py b/packaging/common_utils.py
index 6152e52..1011d0d 100755
--- a/packaging/common_utils.py
+++ b/packaging/common_utils.py
@@ -737,11 +737,12 @@
         db_dict['username'] == 'admin' and
         db_dict['password'] == 'dummy'
     ):
-        output, rc = runPostgresSuQuery(
-            query='"select 1;"',
-            database=db_dict['dbname'],
-            failOnError=False,
-        )
+        if localHost(db_dict['host']):
+            output, rc = runPostgresSuQuery(
+                query='"select 1;"',
+                database=db_dict['dbname'],
+                failOnError=False,
+            )
     else:
         output, rc = execSqlCmd(
             db_dict=db_dict,
@@ -751,8 +752,7 @@
     if rc == 0:
         exists = True
         if (
-            db_dict['username'] != db_dict['engine_user'] and
-            db_dict != 'admin'
+            db_dict['username'] == DB_ADMIN
         ):
             owner = True
 
@@ -1117,7 +1117,7 @@
 def restorePgHba():
     return configHbaIdent('ident', 'md5')
 
-def updatePgHba(username, database, engine):
+def updatePgHba(username, database):
     content = []
     updated = False
     logging.debug('Updating pghba')
@@ -1167,12 +1167,12 @@
     )
 
 
-def createRole(database, username, password, engine):
+def createRole(database, username, password):
     createUser(
         user=username,
         password=password,
     )
-    updatePgHba(username, database, engine)
+    updatePgHba(username, database)
     restartPostgres()
 
 
diff --git a/packaging/ovirt-engine-reports-setup.py 
b/packaging/ovirt-engine-reports-setup.py
index 4f5176c..b03a5d2 100755
--- a/packaging/ovirt-engine-reports-setup.py
+++ b/packaging/ovirt-engine-reports-setup.py
@@ -396,10 +396,6 @@
         },
     ):
         exists, owned = utils.dbExists(dbdict, TEMP_PGPASS)
-        if exists:
-            db_dict['username'] = dbdict['username']
-            db_dict['password'] = dbdict['password']
-            break
 
     return exists, owned
 
@@ -994,15 +990,14 @@
                     'and execute: \"ovirt-engine-dwh-setup\" before setting up 
the '
                     'reports.'
                 )
-
             DB_EXIST, owned = getDBStatus(db_dict, TEMP_PGPASS)
             if dblocal:
-                utils.createRole(
-                    database=db_dict['dbname'],
-                    username=db_dict['username'],
-                    password=db_dict['password'],
-                    engine=db_dict['engine_user'],
-                )
+                if not utils.userExists(db_dict['username']):
+                    utils.createRole(
+                        database=db_dict['dbname'],
+                        username=db_dict['username'],
+                        password=db_dict['password'],
+                    )
                 if DB_EXIST and not owned:
                     logging.debug(
                         (
@@ -1018,13 +1013,12 @@
             elif not DB_EXIST:
                 logging.debug(
                     (
-                        'Remote database {database} found, '
-                        'not owned by reports user'
+                        'Remote database {database} not found'
                     ).format(
                         database=db_dict['dbname']
                     )
                 )
-                print 'Remote database found.'
+                print 'Remote database not found.'
 
                 db_dict['host'] = options['REMOTE_DB_HOST']
                 db_dict['port'] = options['REMOTE_DB_PORT']


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

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

Reply via email to