Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: setup: do not modify jasperserver files ......................................................................
packaging: setup: do not modify jasperserver files this requires two simple patches[1] that fixes jasper build. build configuration is stored at: /var/lib/ovirt-engine-reports/build-conf war is stored at: /var/lib/ovirt-engine-reports/ovirt-engine-reports.war symlink is installed to avoid patching jasper: /var/lib/ovirt-engine-reports/standalone/deployments -> .. [1] http://gerrit.ovirt.org/#/c/23303/ Change-Id: I7eaa6f20d444b82161571d2abc2d7b9f78faa626 Signed-off-by: Alon Bar-Lev <alo...@redhat.com> --- M .gitignore M Makefile M ovirt-engine-reports.spec.in D packaging/conf/default_master.properties A packaging/conf/default_master.properties.in M packaging/legacy-setup/common_utils.py M packaging/legacy-setup/ovirt-engine-reports-setup.py 7 files changed, 84 insertions(+), 94 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/17/23317/1 diff --git a/.gitignore b/.gitignore index 1123229..9dac30b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,6 @@ ########################### build/python-check.sh.in 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 2894fbb..9e5a90b 100644 --- a/Makefile +++ b/Makefile @@ -120,6 +120,7 @@ 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/ovirt-engine-reports.spec.in b/ovirt-engine-reports.spec.in index 9e3257d..bcb5a6f 100644 --- a/ovirt-engine-reports.spec.in +++ b/ovirt-engine-reports.spec.in @@ -43,7 +43,7 @@ BuildRequires: make BuildRequires: maven -Requires: jasperreports-server >= 5.2.0 +Requires: jasperreports-server >= 5.5.0-3 Requires: java-1.7.0-openjdk Requires: jpackage-utils Requires: m2crypto diff --git a/packaging/conf/default_master.properties b/packaging/conf/default_master.properties deleted file mode 100644 index 3be321f..0000000 --- a/packaging/conf/default_master.properties +++ /dev/null @@ -1,35 +0,0 @@ -appServerType=jboss7 - -# JBoss app server root dir -appServerDir=/var/lib/ovirt-engine-reports - -# database type -dbType=postgresql - -# database location and connection settings -dbHost=localhost -dbPort=5432 -dbUsername=postgres -dbPassword=postgres - -# 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 - -# JDBC driver -# (uncomment to change to a non-default setting) -# -# driver will be found here: <path>/buildomatic/conf_source/db/postgresql/jdbc -# -# maven.jdbc.groupId=postgresql -# maven.jdbc.artifactId=postgresql -maven.jdbc.version=jdbc - -# Skip JDBC Driver Deploy -# Flag used to skip JDBC driver deploying during deployment process -# (uncomment to change to a non-default setting) -deployJDBCDriver=false - diff --git a/packaging/conf/default_master.properties.in b/packaging/conf/default_master.properties.in new file mode 100644 index 0000000..84d32ba --- /dev/null +++ b/packaging/conf/default_master.properties.in @@ -0,0 +1,30 @@ +# File locations +reportsHome=@PKG_STATE_DIR@ +reportsWar=${reportsHome}/ovirt-engine-reports.war +currentConf=${reportsHome}/build-conf +appServerDir=${reportsHome} + +appServerType=jboss7 + +# database type +dbType=postgresql + +# database location and connection settings +dbHost=localhost +dbPort=5432 +dbUsername=postgres +dbPassword=postgres + +# 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 + +# Database +maven.jdbc.groupId=postgresql +maven.jdbc.artifactId=postgresql +maven.jdbc.version=9.2-1002.jdbc4 +deployJDBCDriver=false + diff --git a/packaging/legacy-setup/common_utils.py b/packaging/legacy-setup/common_utils.py index 9ce7214..15fb4af 100755 --- a/packaging/legacy-setup/common_utils.py +++ b/packaging/legacy-setup/common_utils.py @@ -483,6 +483,7 @@ env = os.environ.copy() if not "PGPASSFILE" in env: env["PGPASSFILE"] = FILE_PG_PASS + env["ADDITIONAL_CONFIG_DIR"] = "/var/lib/ovirt-engine-reports/build-conf" pi = subprocess.Popen( command, @@ -1046,6 +1047,7 @@ env["PGPASSFILE"] = env["ENGINE_PGPASS"] else: env["PGPASSFILE"] = FILE_PG_PASS + env["ADDITIONAL_CONFIG_DIR"] = "/var/lib/ovirt-engine-reports/build-conf" # We use close_fds to close any file descriptors we have so it won't be copied to forked childs proc = subprocess.Popen( diff --git a/packaging/legacy-setup/ovirt-engine-reports-setup.py b/packaging/legacy-setup/ovirt-engine-reports-setup.py index 9aaf3c9..390b119 100755 --- a/packaging/legacy-setup/ovirt-engine-reports-setup.py +++ b/packaging/legacy-setup/ovirt-engine-reports-setup.py @@ -55,7 +55,6 @@ REPORTS_SERVER_DIR = "/usr/share/%s" % JRS_PACKAGE_NAME REPORTS_SERVER_BUILDOMATIC_DIR = "%s/buildomatic" % REPORTS_SERVER_DIR REPORTS_DB_UPGRADE_SCRIPTS_DIR = "%s/install_resources/sql/postgresql" % REPORTS_SERVER_BUILDOMATIC_DIR -FILE_JASPER_DB_CONN = "%s/default_master.properties" % REPORTS_SERVER_BUILDOMATIC_DIR FILE_DATABASE_ENGINE_CONFIG = "/etc/ovirt-engine/engine.conf.d/10-setup-database.conf" FILE_DATABASE_DWH_CONFIG = "/etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d/10-setup-database.conf" FILE_DATABASE_REPORTS_CONFIG = "/etc/ovirt-engine-reports/ovirt-engine-reports.conf.d/10-setup-database.conf" @@ -183,6 +182,7 @@ execute js-ant with various directives ''' global DB_EXIST + configFile = None try: logging.debug("Deploying Server ant scripts") current_dir = os.getcwd() @@ -208,14 +208,23 @@ if isWarInstalled(): shutil.rmtree(DIR_WAR) - logging.debug("Linking Postgresql JDBC driver to %s/conf_source/db/postgresql/jdbc for installation" % REPORTS_SERVER_BUILDOMATIC_DIR) - shutil.copyfile("/usr/share/java/postgresql-jdbc.jar", "%s/conf_source/db/postgresql/jdbc/postgresql-jdbc.jar" % REPORTS_SERVER_BUILDOMATIC_DIR) - # create DB if it didn't exist: if not DB_EXISTED and utils.localHost(db_dict['host']): logging.debug('Creating DB') utils.createDB(db_dict) utils.createLang(db_dict, TEMP_PGPASS) + + # + # workaround for not modify jasper faulty build + # + if not os.path.exists('/var/lib/ovirt-engine-reports/standalone'): + os.mkdir('/var/lib/ovirt-engine-reports/standalone') + os.symlink('..', '/var/lib/ovirt-engine-reports/standalone/deployments') + + # Set db connectivity (user/pass) + logging.debug("Username is %s" % db_dict["username"]) + configFile = setDBConn() + logging.debug("Installing Jasper") for cmd in ( 'init-js-db-ce', @@ -224,6 +233,7 @@ ): cmdList = [ './js-ant', + '-DmasterPropsSource=%s' % configFile, cmd ] output, rc = utils.execCmd( @@ -241,12 +251,20 @@ logging.debug("Removing deployment of Postgresql JDBC driver and unused dodeploy file post installation") for obsolete_file in ( - "%s/postgresql-jdbc.jar" % DIR_DEPLOY, - "%s/WEB-INF/lib/postgresql-jdbc.jar" % DIR_WAR, "%s/%s.war.dodeploy" % (DIR_DEPLOY,JRS_APP_NAME), ): if os.path.exists(obsolete_file): os.remove(obsolete_file) + + # replace built-in driver with our jboss one + jboss7ds = os.path.join(DIR_DEPLOY, 'ovirt-engine-reports.war/WEB-INF/js-jboss7-ds.xml') + with open(jboss7ds) as f: + content = f.read().splitlines() + for i, l in enumerate(content): + if '<driver>' in l: + content[i] = '<driver>postgresql</driver>' + with open(jboss7ds, 'w') as f: + f.write('\n'.join(content) + '\n') # Restore the smtp configuration file if os.path.exists(tempSmtpFile): @@ -260,25 +278,8 @@ os.chdir(current_dir) if os.path.exists(tempSmtpFile): os.remove(tempSmtpFile) - -def setDeploymentDetails(db_dict): - ''' - set the password for the user postgres - ''' - logging.debug("Setting DB pass") - - logging.debug("editing jasper db connectivity file") - file_handler = utils.TextConfigFileHandler(FILE_JASPER_DB_CONN) - 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() + if configFile: + os.remove(configFile) def setReportsDatasource(dir, db_dict): f = os.path.join(dir, 'resources/reports_resources/JDBC/data_sources/ovirt.xml') @@ -325,13 +326,31 @@ envDict={'ENGINE_PGPASS': TEMP_PGPASS}, ) -@transactionDisplay("Setting DB connectivity") def setDBConn(): - shutil.copyfile("%s/conf/default_master.properties" % REPORTS_PACKAGE_DIR, FILE_JASPER_DB_CONN) - if db_dict['password']: - setDeploymentDetails(db_dict) - else: + if not db_dict['password']: raise OSError("Cannot find password for db") + + 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() + + return f def getDbDictFromOptions(): db_dict = { @@ -814,22 +833,6 @@ else: return False -@transactionDisplay("Editing XML files") -def editXmlFiles(): - logging.debug("Editing xml files for jasper installation") - for file in ["setup.xml", "app-server.xml"]: - logging.debug("reading %s" % file) - fd = open("%s/bin/%s" % (REPORTS_SERVER_BUILDOMATIC_DIR, file), "r") - file_content = fd.read() - fd.close() - logging.debug("replace install path to correct one") - file_content = file_content.replace("/${jboss7.profile}/deployments", "") - logging.debug("writing replaced content to %s" % file) - fd = open("%s/bin/%s" % (REPORTS_SERVER_BUILDOMATIC_DIR, file), "w") - fd.write(file_content) - logging.debug("closing file") - fd.close() - def updateDsJdbc(): """ Updating datasource to point to jdbc module. @@ -1110,15 +1113,6 @@ _exitBadState() - # Edit setup.xml & app-server.xml to remove profile name - if not warUpdated or not isWarInstalled(): - editXmlFiles() - - logging.debug("Username is %s" % db_dict["username"]) - # Set db connectivity (user/pass) - if not warUpdated or not isWarInstalled(): - setDBConn() - if not warUpdated and isWarInstalled(): backupWAR() with open(FILE_DEPLOY_VERSION, 'r') as verfile: @@ -1199,9 +1193,6 @@ # Copy reports xml to engine shutil.copy2("%s/conf/reports.xml" % REPORTS_PACKAGE_DIR, '/var/lib/ovirt-engine/reports.xml') - # Delete default properties files - if os.path.exists(FILE_JASPER_DB_CONN): - os.remove(FILE_JASPER_DB_CONN) # Delete Jasper's Temp Folder # Delete Data Snapshots Folder, for path in ( -- To view, visit http://gerrit.ovirt.org/23317 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7eaa6f20d444b82161571d2abc2d7b9f78faa626 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-reports Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches