Juan Hernandez has uploaded a new change for review.

Change subject: packaging: Add support for absolute app path
......................................................................

packaging: Add support for absolute app path

Currently the applications listed in the ENGINE_APPS configuration
parameter are assumed to exist under the /usr/share/ovirt-engine
directory. This change adds support for absolute application paths, this
will help when deploying applications from other directories.

Change-Id: I30abd8c33bf4e879372dc3cf43b55f24ccdcfd6d
Signed-off-by: Juan Hernandez <[email protected]>
---
M Makefile
M backend/manager/conf/engine.conf.defaults.in
M packaging/fedora/engine-service.py.in
3 files changed, 75 insertions(+), 63 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/96/13796/1

diff --git a/Makefile b/Makefile
index a8ceef3..090b40f 100644
--- a/Makefile
+++ b/Makefile
@@ -114,6 +114,11 @@
        -e "s|@ENGINE_VAR@|$(ENGINE_STATE)|g" \
        -e "s|@ENGINE_CACHE@|$(PKG_CACHE_DIR)|g" \
        -e "s|@ENGINE_PID@|$(PID_DIR)/$(ENGINE_NAME).pid|g" \
+       -e "s|@ENGINE_BEANS@|$(PKG_BEANS_DIR)|g" \
+       -e "s|@ENGINE_ROOT@|$(PKG_ROOT_DIR)|g" \
+       -e "s|@ENGINE_RESTAPI@|$(PKG_RESTAPI_DIR)|g" \
+       -e "s|@ENGINE_USERPORTAL@|$(PKG_USERPORTAL_DIR)|g" \
+       -e "s|@ENGINE_WEBADMIN@|$(PKG_WEBADMIN_DIR)|g" \
        -e "s|@RPM_VERSION@|$(RPM_VERSION)|g" \
        -e "s|@RPM_RELEASE@|$(RPM_RELEASE)|g" \
        -e "s|@PACKAGE_NAME@|$(PACKAGE_NAME)|g" \
diff --git a/backend/manager/conf/engine.conf.defaults.in 
b/backend/manager/conf/engine.conf.defaults.in
index 8acae93..1f22964 100644
--- a/backend/manager/conf/engine.conf.defaults.in
+++ b/backend/manager/conf/engine.conf.defaults.in
@@ -91,9 +91,14 @@
 #
 # 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 /usr/share/ovirt-engine:
+# directories that should be either absolute or relative to the value of
+# the ENGINE_USR parameter:
 #
-ENGINE_APPS="beans.jar restapi.war root.war userportal.war webadmin.war"
+ENGINE_APPS="@ENGINE_BEANS@"
+ENGINE_APPS="${ENGINE_APPS} @ENGINE_ROOT@"
+ENGINE_APPS="${ENGINE_APPS} @ENGINE_RESTAPI@"
+ENGINE_APPS="${ENGINE_APPS} @ENGINE_USERPORTAL@"
+ENGINE_APPS="${ENGINE_APPS} @ENGINE_WEBADMIN@"
 
 #
 # Flags to enable or disable the web server (the proxy) and the
diff --git a/packaging/fedora/engine-service.py.in 
b/packaging/fedora/engine-service.py.in
index e450ad1..f14fb51 100644
--- a/packaging/fedora/engine-service.py.in
+++ b/packaging/fedora/engine-service.py.in
@@ -465,82 +465,84 @@
             )
 
     def _setupEngineApps(self):
+        for app in self._config.getString('ENGINE_APPS').split():
+            self._setupEngineApp(app)
 
-        # The list of applications to be deployed:
-        for engineApp in self._config.getString('ENGINE_APPS').split():
-            # Do nothing if the application is not available:
-            engineAppDir = os.path.join(
+    def _setupEngineApp(self, app):
+        # If the given application is not an absolute path then
+        # try to locate it in the resources directory:
+        if not os.path.isabs(app):
+            app = os.path.join(
                 self._config.getString('ENGINE_USR'),
-                engineApp,
+                app,
             )
-            if not os.path.exists(engineAppDir):
-                self._logger.warning(
-                    _(
-                        "Application '{application}' directory '{directory}' "
-                        "does not exist, it will be ignored"
-                    ).format(
-                        application=engineApp,
-                        directory=engineAppDir,
-                    ),
-                )
-                continue
-
-            # Make sure the application is linked in the deployments
-            # directory, if not link it now:
-            engineAppLink = os.path.join(
-                self._config.getString('ENGINE_VAR'),
-                'deployments',
-                engineApp,
+        if not os.path.exists(app):
+            self._logger.warning(
+                _(
+                    "Application '{app}' does not exist, "
+                    "it will be ignored"
+                ).format(
+                    app=app,
+                ),
             )
-            if not os.path.islink(engineAppLink):
-                try:
-                    os.symlink(engineAppDir, engineAppLink)
-                except OSError as e:
-                    self._logger.debug('exception', exc_info=True)
-                    raise RuntimeError(
-                        _(
-                            "Cannot create symbolic link '{file}': "
-                            "{error}"
-                        ).format(
-                            file=engineAppLink,
-                            error=e,
-                        ),
-                    )
+            return
 
-            # Remove all existing deployment markers:
-            for markerFile in glob.glob('%s.*' % engineAppLink):
-                try:
-                    os.remove(markerFile)
-                except OSError as e:
-                    self._logger.debug('exception', exc_info=True)
-                    raise RuntimeError(
-                        _(
-                            "Cannot remove deployment marker file '{file}': "
-                            "{error}"
-                        ).format(
-                            file=markerFile,
-                            error=e,
-                        ),
-                    )
-
-            # Create the new marker file to trigger deployment
-            # of the application:
-            markerFile = "%s.dodeploy" % engineAppLink
+        # Make sure the application is linked in the deployments
+        # directory, if not link it now:
+        appLink = os.path.join(
+            self._config.getString('ENGINE_VAR'),
+            'deployments',
+            os.path.basename(app),
+        )
+        if not os.path.islink(appLink):
             try:
-                with open(markerFile, "w"):
-                    pass
-            except IOError as e:
+                os.symlink(app, appLink)
+            except OSError as e:
                 self._logger.debug('exception', exc_info=True)
                 raise RuntimeError(
                     _(
-                        "Cannot create deployment marker file '{file}': "
+                        "Cannot create symbolic link '{file}': "
+                        "{error}"
+                    ).format(
+                        file=appLink,
+                        error=e,
+                    ),
+                )
+
+        # Remove all existing deployment markers:
+        for markerFile in glob.glob('%s.*' % appLink):
+            try:
+                os.remove(markerFile)
+            except OSError as e:
+                self._logger.debug('exception', exc_info=True)
+                raise RuntimeError(
+                    _(
+                        "Cannot remove deployment marker file '{file}': "
                         "{error}"
                     ).format(
                         file=markerFile,
                         error=e,
-                    )
+                    ),
                 )
 
+        # Create the new marker file to trigger deployment
+        # of the application:
+        markerFile = "%s.dodeploy" % appLink
+        try:
+            with open(markerFile, "w"):
+                pass
+        except IOError as e:
+            self._logger.debug('exception', exc_info=True)
+            raise RuntimeError(
+                _(
+                    "Cannot create deployment marker file '{file}': "
+                    "{error}"
+                ).format(
+                    file=markerFile,
+                    error=e,
+                )
+            )
+
     def _daemon(self, args, executable, env):
 
         self._logger.debug(


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

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

Reply via email to