Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: raising on invalid application mode values
......................................................................

packaging: setup: raising on invalid application mode values

It was treating every invalid application mode values as
virtOnly. Checking it for a more consistent behavior.
The default value for ApplicationMode at DB creation is
AllModes = 255; making it more explicit.

Change-Id: Ic47e171ddc76a9881e4a915f62dbae762a72f9f8
Bug-Url: https://bugzilla.redhat.com/1149575
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
---
M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/appmode.py
1 file changed, 26 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/92/39392/1

diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/appmode.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/appmode.py
index 393e226..40440ad 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/appmode.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/config/appmode.py
@@ -41,6 +41,7 @@
     class ApplicationMode(object):
         VirtOnly = 1
         GlusterOnly = 2
+        AllModes = 255
 
     def __init__(self, context):
         super(Plugin, self).__init__(context=context)
@@ -81,10 +82,7 @@
             oengcommcons.Stages.DIALOG_TITLES_S_ENGINE,
             oenginecons.Stages.APPMODE_ALLOWED,
         ),
-        condition=lambda self: (
-            self._enabled and
-            self.environment[oenginecons.EngineDBEnv.NEW_DATABASE]
-        ),
+        condition=lambda self: self._enabled,
         name=osetupcons.Stages.CONFIG_APPLICATION_MODE_AVAILABLE,
     )
     def _customization(self):
@@ -139,23 +137,31 @@
             ),
         )
 
-        if v != 'both':
-            self.environment[oenginecons.EngineDBEnv.STATEMENT].execute(
-                statement="""
-                    select fn_db_update_config_value(
-                        'ApplicationMode',
-                        %(mode)s,
-                        'general'
-                    )
-                """,
-                args=dict(
-                    mode=str(
-                        self.ApplicationMode.GlusterOnly
-                        if v == 'gluster'
-                        else self.ApplicationMode.VirtOnly
-                    ),
-                ),
+        if v == 'virt':
+            mode = self.ApplicationMode.VirtOnly
+        elif v == 'gluster':
+            mode = self.ApplicationMode.GlusterOnly
+        elif v == 'both':
+            mode = self.ApplicationMode.AllModes
+        else:
+            raise RuntimeError(
+                _('Selected application mode \'{v}\' is not allowed').format(
+                    v=v,
+                )
             )
 
+        self.environment[oenginecons.EngineDBEnv.STATEMENT].execute(
+            statement="""
+                select fn_db_update_config_value(
+                    'ApplicationMode',
+                    %(mode)s,
+                    'general'
+                )
+            """,
+            args=dict(
+                mode=str(mode),
+            ),
+        )
+
 
 # vim: expandtab tabstop=4 shiftwidth=4


-- 
To view, visit https://gerrit.ovirt.org/39392
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic47e171ddc76a9881e4a915f62dbae762a72f9f8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to