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

Change subject: packaging: setup: process jasper configuration as template
......................................................................

packaging: setup: process jasper configuration as template

Change-Id: I06c52154c28d886f09fd948dd3fa6bcf39ca6905
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M .gitignore
M Makefile
M packaging/conf/default_master.properties.in
M packaging/legacy-setup/ovirt-engine-reports-setup.py
4 files changed, 25 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/13/23413/1

diff --git a/.gitignore b/.gitignore
index 8a039b3..fae2f8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,6 +16,5 @@
 ###########################
 build/python-check.sh
 ovirt-engine-reports.spec
-packaging/conf/default_master.properties
 packaging/sys-etc/ovirt-engine/engine.conf.d/50-ovirt-engine-reports.conf
 server-customizations/WEB-INF/log4j.properties
diff --git a/Makefile b/Makefile
index 9e5a90b..2894fbb 100644
--- a/Makefile
+++ b/Makefile
@@ -120,7 +120,6 @@
 GENERATED = \
        build/python-check.sh \
        ovirt-engine-reports.spec \
-       packaging/conf/default_master.properties \
        
packaging/sys-etc/ovirt-engine/engine.conf.d/50-ovirt-engine-reports.conf \
        server-customizations/WEB-INF/log4j.properties \
        $(NULL)
diff --git a/packaging/conf/default_master.properties.in 
b/packaging/conf/default_master.properties.in
index 84d32ba..df02ffa 100644
--- a/packaging/conf/default_master.properties.in
+++ b/packaging/conf/default_master.properties.in
@@ -10,17 +10,17 @@
 dbType=postgresql
 
 # database location and connection settings
-dbHost=localhost
-dbPort=5432
-dbUsername=postgres
-dbPassword=postgres
+dbHost=@REPORTS_DB_HOST@
+dbPort=@REPORTS_DB_PORT@
+dbUsername=@REPORTS_DB_USER@
+dbPassword=@REPORTS_DB_PASSWORD@
 
 # JasperServer db name
 js.dbName=ovirtenginereports
 
 # web app name
 # (set one of these to deploy to a non-default war file name)
-webAppNameCE=ovirt-engine-reports
+webAppNameCE=@PACKAGE_NAME@
 
 # Database
 maven.jdbc.groupId=postgresql
diff --git a/packaging/legacy-setup/ovirt-engine-reports-setup.py 
b/packaging/legacy-setup/ovirt-engine-reports-setup.py
index 89d9752..66ad48f 100755
--- a/packaging/legacy-setup/ovirt-engine-reports-setup.py
+++ b/packaging/legacy-setup/ovirt-engine-reports-setup.py
@@ -35,11 +35,11 @@
     'REMOTE_DB_PASSWORD': None,
 }
 
-DIR_DEPLOY = "/var/lib/ovirt-engine-reports"
+PKG_STATE_DIR = "/var/lib/ovirt-engine-reports"
 JRS_APP_NAME = "ovirt-engine-reports"
 JRS_DB_NAME = "ovirtenginereports"
 JRS_PACKAGE_NAME = "jasperreports-server"
-DIR_WAR="%s/%s.war" % (DIR_DEPLOY, JRS_APP_NAME)
+DIR_WAR="%s/%s.war" % (PKG_STATE_DIR, JRS_APP_NAME)
 LEGACY_WAR="/usr/share/ovirt-engine/ovirt-engine-reports.war"
 FILE_JS_SMTP="%s/WEB-INF/js.quartz.properties" % DIR_WAR
 FILE_APPLICATION_CONTEXT_OVERRIDE 
="%s/WEB-INF/applicationContext-ovirt-override.xml" % DIR_WAR
@@ -253,13 +253,13 @@
         for obsolete_file in (
             glob.glob(
                 os.path.join(
-                    DIR_DEPLOY,
+                    PKG_STATE_DIR,
                     '*.war.dodeploy',
                 )
             ) +
             glob.glob(
                 os.path.join(
-                    DIR_DEPLOY,
+                    PKG_STATE_DIR,
                     '*.war/WEB-INF/lib/postgresql-*.jar',
                 )
             )
@@ -334,22 +334,23 @@
     fd, f = tempfile.mkstemp()
     os.close(fd)
 
-    shutil.copyfile("%s/conf/default_master.properties" % REPORTS_PACKAGE_DIR, 
f)
-
-    logging.debug("Setting DB pass")
-
     logging.debug("editing jasper db connectivity file")
-    file_handler = utils.TextConfigFileHandler(f)
-    file_handler.open()
-    # TODO: when JS support for passwords with $$ is added, remove 'replace'
-    file_handler.editParam("dbPassword", db_dict["password"].replace("$", 
"$$"))
-    file_handler.editParam("dbUsername", db_dict["username"])
-    file_handler.editParam("dbHost", db_dict["host"])
-    file_handler.editParam("dbPort", db_dict["port"])
-    file_handler.editParam("js.dbName", db_dict['dbname'])
-    file_handler.editParam("webAppNameCE", JRS_APP_NAME)
-    file_handler.editParam("appServerDir", DIR_DEPLOY)
-    file_handler.close()
+    utils.processTemplate(
+        os.path.join(
+            REPORTS_PACKAGE_DIR,
+            'conf',
+            'default_master.properties.in',
+        ),
+        f,
+        subst={
+            '@PACKAGE_NAME@': JRS_APP_NAME,
+            '@PKG_STATE_DIR@': PKG_STATE_DIR,
+            '@REPORTS_DB_HOST@': db_dict["host"],
+            '@REPORTS_DB_PORT@': db_dict["port"],
+            '@REPORTS_DB_USER@': db_dict["username"],
+            '@REPORTS_DB_PASSWORD@': db_dict["password"].replace("$", "$$"),
+        },
+    )
 
     return f
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I06c52154c28d886f09fd948dd3fa6bcf39ca6905
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-reports
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