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

Change subject: packaging: support modifying java module path
......................................................................

packaging: support modifying java module path

if a customer need to have more recent version of module, he currently
have no way to apply except of replacing pre-installed files.

this change allows customer to add his own module path to search path to
shadow product modules.

Change-Id: Ibda53f67fa801cf4eb00b11483e9a6ab712d4d74
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M packaging/bin/engine-prolog.sh.in
M packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
M packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.py
M packaging/services/ovirt-engine/ovirt-engine.conf.in
M packaging/services/ovirt-engine/ovirt-engine.py
5 files changed, 67 insertions(+), 44 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/86/19586/1

diff --git a/packaging/bin/engine-prolog.sh.in 
b/packaging/bin/engine-prolog.sh.in
index 432d58f..1cc673f 100644
--- a/packaging/bin/engine-prolog.sh.in
+++ b/packaging/bin/engine-prolog.sh.in
@@ -26,7 +26,7 @@
 
        # we use jboss specific loader (jboss-modules.jar)
        # setup module path
-       export JAVA_MODULEPATH="${ENGINE_USR}/modules:${JBOSS_HOME}/modules"
+       export JAVA_MODULEPATH="${ENGINE_JAVA_MODULEPATH}:${JBOSS_HOME}/modules"
 
        # clean the class path
        # jboss module loader will not run otherwise.
diff --git 
a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in 
b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
index 8fd1c1d..c3753f8 100644
--- a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
+++ b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in
@@ -21,6 +21,14 @@
 ENGINE_USR="@ENGINE_USR@"
 
 #
+# Module path
+#
+# JBoss is always appended, cannot be appended here
+# as it may be resolved to different value.
+#
+ENGINE_JAVA_MODULEPATH="${ENGINE_USR}/modules"
+
+#
 # Service timeouts
 #
 NOTIFIER_STOP_TIME=30
diff --git a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.py 
b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.py
index 96266ae..0c77860 100755
--- a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.py
+++ b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.py
@@ -160,16 +160,13 @@
             'LANG': 'en_US.UTF-8',
             'LC_ALL': 'en_US.UTF-8',
             'CLASSPATH': '',
-            'JAVA_MODULEPATH': ':'.join([
-                os.path.join(
-                    self._config.get('ENGINE_USR'),
-                    'modules',
-                ),
+            'JAVA_MODULEPATH': '%s:%s' % (
+                self._config.get('ENGINE_JAVA_MODULEPATH'),
                 os.path.join(
                     self._config.get('JBOSS_HOME'),
                     'modules',
-                ),
-            ]),
+                )
+            ),
             'ENGINE_DEFAULTS': config.ENGINE_DEFAULTS,
             'ENGINE_VARS': config.ENGINE_VARS,
             'ENGINE_NOTIFIER_DEFAULTS': self._defaults,
diff --git a/packaging/services/ovirt-engine/ovirt-engine.conf.in 
b/packaging/services/ovirt-engine/ovirt-engine.conf.in
index 30a760c..8a6cc4f 100644
--- a/packaging/services/ovirt-engine/ovirt-engine.conf.in
+++ b/packaging/services/ovirt-engine/ovirt-engine.conf.in
@@ -119,6 +119,14 @@
 ENGINE_JVM_ARGS="${ENGINE_JVM_ARGS} -XX:HeapDumpPath=\"${ENGINE_LOG}/dump\""
 
 #
+# Module path
+#
+# JBoss is always appended, cannot be appended here
+# as it may be resolved to different value.
+#
+ENGINE_JAVA_MODULEPATH="${ENGINE_USR}/modules"
+
+#
 # Additional applications to be deployed in the instance of the
 # application server started by the engine. This is a list of space
 # separated files or directories that should exist under
diff --git a/packaging/services/ovirt-engine/ovirt-engine.py 
b/packaging/services/ovirt-engine/ovirt-engine.py
index d7eafdc..a948903 100755
--- a/packaging/services/ovirt-engine/ovirt-engine.py
+++ b/packaging/services/ovirt-engine/ovirt-engine.py
@@ -56,29 +56,47 @@
             f.write(str(Template(file=template, searchList=[self._config])))
         return out
 
-    def _linkModules(self, modulesDir):
-        """Link all the JBoss modules into a temporary directory"""
+    def _linkModules(self, modulePath):
+        """
+            Link all the JBoss modules into a temporary directory.
+            This required because jboss tries to automatically update
+            indexes based on timestamp even if there is no permission to do so.
+        """
 
-        modulesTmpDir = os.path.join(
-            self._config.get('ENGINE_TMP'),
-            'modules',
-        )
+        modifiedModulePath = []
+        for index, element in enumerate(modulePath.split(':')):
+            modulesTmpDir = os.path.join(
+                self._config.get('ENGINE_TMP'),
+                'modules',
+                '%02d-%s' % (
+                    index,
+                    '-'.join(element.split(os.sep)[-2:]),
+                ),
+            )
+            modifiedModulePath.append(modulesTmpDir)
 
-        # For each directory in the modules directory create the same in the
-        # temporary directory and populate with symlinks pointing to the
-        # original files (excluding indexes):
-        for parentDir, childrenDirs, childrenFiles in os.walk(modulesDir):
-            parentTmpDir = parentDir.replace(modulesDir, modulesTmpDir, 1)
-            if not os.path.exists(parentTmpDir):
-                os.makedirs(parentTmpDir)
-            for childFile in childrenFiles:
-                if childFile.endswith('.index'):
-                    continue
-                childPath = os.path.join(parentDir, childFile)
-                childTmpPath = os.path.join(parentTmpDir, childFile)
-                os.symlink(childPath, childTmpPath)
+            # For each directory in the modules directory create the
+            # same in the temporary directory and populate with symlinks
+            # pointing to the original files (excluding indexes):
+            for parentDir, childrenDirs, childrenFiles in os.walk(element):
+                parentTmpDir = os.path.join(
+                    modulesTmpDir,
+                    os.path.relpath(
+                        parentDir,
+                        element
+                    ),
+                )
+                if not os.path.exists(parentTmpDir):
+                    os.makedirs(parentTmpDir)
+                for childFile in childrenFiles:
+                    if childFile.endswith('.index'):
+                        continue
+                    os.symlink(
+                        os.path.join(parentDir, childFile),
+                        os.path.join(parentTmpDir, childFile)
+                    )
 
-        return modulesTmpDir
+        return ':'.join(modifiedModulePath)
 
     def _checkInstallation(
         self,
@@ -292,10 +310,13 @@
             'config',
         )
 
-        jbossModulesTmpDir = self._linkModules(
-            os.path.join(
-                self._config.get('JBOSS_HOME'),
-                'modules',
+        javaModulePath = self._linkModules(
+            '%s:%s' % (
+                self._config.get('ENGINE_JAVA_MODULEPATH'),
+                os.path.join(
+                    self._config.get('JBOSS_HOME'),
+                    'modules',
+                ),
             ),
         )
 
@@ -401,18 +422,7 @@
             '-Djboss.server.temp.dir=%s' % jbossTempDir,
             '-Djboss.controller.temp.dir=%s' % jbossTempDir,
             '-jar', jbossModulesJar,
-
-            # Module path should include first the engine modules
-            # so that they can override those provided by the
-            # application server if needed:
-            '-mp', "%s:%s" % (
-                os.path.join(
-                    self._config.get('ENGINE_USR'),
-                    'modules',
-                ),
-                jbossModulesTmpDir,
-            ),
-
+            '-mp', javaModulePath,
             '-jaxpmodule', 'javax.xml.jaxp-provider',
             'org.jboss.as.standalone',
             '-c', os.path.basename(jbossConfigFile),


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

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

Reply via email to