Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: remove 10-setup-database-dwh.conf from package
......................................................................

packaging: remove 10-setup-database-dwh.conf from package

conf.d files should not be in packaging. marking these as %config is
even worse and will not enable proper upgrade.

Change-Id: I798d59c469067c0eba93a8a19859e07f958baa0b
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M Makefile
D packaging/10-setup-database-dwh.conf
M packaging/ovirt-engine-dwh-setup.py
M packaging/ovirt-engine-dwh.spec.in
4 files changed, 30 insertions(+), 46 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/01/22401/1

diff --git a/Makefile b/Makefile
index b08e21b..cef7bf0 100644
--- a/Makefile
+++ b/Makefile
@@ -164,7 +164,6 @@
        cp -a  data-warehouse/history_etl/context_files/* 
$(DESTDIR)$(DATA_DIR)/etl
        cp -r -a  data-warehouse/historydbscripts_postgres/* 
$(DESTDIR)$(DATA_DIR)/db-scripts
        install -p -m 660 
data-warehouse/history_etl/context_files/ovirt_engine_dwh/historyetl_3_3/contexts/Default.properties
 $(DESTDIR)$(SYSCONF_DIR)/ovirt-engine/$(OVIRT_DWH_NAME)
-       install -p -m 660 packaging/10-setup-database-dwh.conf 
$(DESTDIR)$(SYSCONF_DIR)/$(OVIRT_DWH_NAME)/engine-dwh.conf.d
        install -p -m 644 packaging/resources/$(OVIRT_DWH_NAME)d.logrotate 
$(DESTDIR)$(SYSCONF_DIR)/logrotate.d/$(OVIRT_DWH_NAME)d
        install -p -m 755 packaging/resources/ovirt_engine_dwh_watchdog.cron 
$(DESTDIR)$(SYSCONF_DIR)/cron.hourly
 
diff --git a/packaging/10-setup-database-dwh.conf 
b/packaging/10-setup-database-dwh.conf
deleted file mode 100644
index 00468e3..0000000
--- a/packaging/10-setup-database-dwh.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-DWH_USER=engine_history
-DWH_PASSWORD=
-DWH_DATABASE=ovirt_engine_history
diff --git a/packaging/ovirt-engine-dwh-setup.py 
b/packaging/ovirt-engine-dwh-setup.py
index 7934a7e..27c10d1 100755
--- a/packaging/ovirt-engine-dwh-setup.py
+++ b/packaging/ovirt-engine-dwh-setup.py
@@ -261,47 +261,36 @@
     return (dbhost, dbport, dbuser, userInput)
 
 def getDbDictFromOptions():
-    if os.path.exists(FILE_DATABASE_CONFIG):
-        handler = utils.TextConfigFileHandler(FILE_DATABASE_CONFIG)
-        handler.open()
-        dhandler = handler
-        if os.path.exists(FILE_DATABASE_DWH_CONFIG):
-            dhandler = utils.TextConfigFileHandler(FILE_DATABASE_DWH_CONFIG)
-            dhandler.open()
-        db_dict = {
-            'dbname': (
-                dhandler.getParam('DWH_DATABASE') or
-                DB_NAME
-            ),
-            'host': handler.getParam('ENGINE_DB_HOST').strip('"'),
-            'port': handler.getParam('ENGINE_DB_PORT').strip('"'),
-            'username': (
-                dhandler.getParam('DWH_USER') or
-                DB_USER
-            ),
-            'password': (
-                dhandler.getParam('DWH_PASSWORD') or
-                utils.generatePassword()
-            ),
-            'readonly': (
-                dhandler.getParam('DWH_READONLY_USER') or
-                None
-            ),
-            'engine_db': handler.getParam('ENGINE_DB_DATABASE').strip('"'),
-            'engine_user': handler.getParam('ENGINE_DB_USER').strip('"'),
-            'engine_pass': handler.getParam('ENGINE_DB_PASSWORD').strip('"'),
-        }
-        handler.close()
-        dhandler.close()
-    else:
-        db_dict = {
-            'dbname': DB_NAME,
-            'host': utils.getDbHostName(),
-            'port': utils.getDbPort(),
-            'username': utils.getDbAdminUser(),
-            'password': utils.getPassFromFile(utils.getDbAdminUser()),
-            'readonly': None,
-        }
+    db_dict = {
+        'dbname': DB_NAME,
+        'host': utils.getDbHostName(),
+        'port': utils.getDbPort(),
+        'username': utils.getDbAdminUser(),
+        'password': utils.getPassFromFile(utils.getDbAdminUser()),
+        'readonly': None,
+    }
+
+    for file in (FILE_DATABASE_CONFIG, FILE_DATABASE_DWH_CONFIG):
+
+        if os.path.exists(file):
+            handler = utils.TextConfigFileHandler(file)
+            handler.open()
+
+            for k, v in (
+                ('dbname', 'DWH_DATABASE'),
+                ('host', 'ENGINE_DB_HOST'),
+                ('port', 'ENGINE_DB_PORT'),
+                ('username', 'DWH_USER'),
+                ('password', 'DWH_PASSWORD'),
+                ('readonly', 'DWH_READONLY_USER'),
+                ('engine_db', 'ENGINE_DB_DATABASE'),
+                ('engine_user', 'ENGINE_DB_USER'),
+                ('engine_pass', 'ENGINE_DB_PASSWORD'),
+            ):
+                s = handler.getParam(v)
+                if v is not None:
+                    db_dict[k] = v.strip('"')
+            handler.close()
 
     return db_dict
 
diff --git a/packaging/ovirt-engine-dwh.spec.in 
b/packaging/ovirt-engine-dwh.spec.in
index 69977df..96bed14 100644
--- a/packaging/ovirt-engine-dwh.spec.in
+++ b/packaging/ovirt-engine-dwh.spec.in
@@ -131,7 +131,6 @@
 %endif
 
 %dir %attr(-, %{engine_user}, %{engine_group}) 
%{_sysconfdir}/%{dwh_name}/engine-dwh.conf.d
-%config(noreplace) 
%{_sysconfdir}/%{dwh_name}/engine-dwh.conf.d/10-setup-database-dwh.conf
 
 %dir %{_sysconfdir}/ovirt-engine/%{dwh_name}
 %{_initddir}/%{dwh_name}d


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

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

Reply via email to