Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: cluster comp. level as max common between 
vdsm and engine
......................................................................

packaging: setup: cluster comp. level as max common between vdsm and engine

During alpha release the VDSM maximum supported cluster level
will not necessarily matches the engine one.
Chossing the max common between them.

Change-Id: Iaf1b04e7c087ef70ccceb83fdbff8caf7e2942e2
Bug-Url: https://bugzilla.redhat.com/1100236
Signed-off-by: Simone Tiraboschi <[email protected]>
---
M packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/all-in-one/vdsm.py
1 file changed, 35 insertions(+), 8 deletions(-)


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

diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/all-in-one/vdsm.py 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/all-in-one/vdsm.py
index 850ffc1..d3bcfa0 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/all-in-one/vdsm.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine/all-in-one/vdsm.py
@@ -28,7 +28,7 @@
 
 from otopi import util
 from otopi import plugin
-
+from vdsm import vdscli
 
 from ovirt_engine_setup import constants as osetupcons
 from ovirt_engine_setup.engine import constants as oenginecons
@@ -195,25 +195,52 @@
         self.logger.debug('Connecting to the Engine')
         engine_api = self._waitEngineUp()
 
-        SupportedClusterLevels = vdcoption.VdcOption(
+        eSupportedClusterLevels = vdcoption.VdcOption(
             statement=self.environment[
                 oenginecons.EngineDBEnv.STATEMENT
             ]
         ).getVdcOption(
             name='SupportedClusterLevels'
         )
-
         self.logger.debug(
-            'SupportedClusterLevels [{levels}], '
+            'engine SupportedClusterLevels [{levels}], '
             'PACKAGE_VERSION [{pv}],'.format(
-                levels=SupportedClusterLevels,
+                levels=eSupportedClusterLevels,
                 pv=osetupconfig.PACKAGE_VERSION,
             )
         )
-        v = max(
-            distutils.version.LooseVersion(vs).version
-            for vs in SupportedClusterLevels.split(',')
+
+        result = vdscli.connect().getVdsCapabilities()
+        code, message = result['status']['code'], result['status']['message']
+        if code != 0 or 'info' not in result:
+            raise RuntimeError(
+                'Failed to get vds capabilities. Error code: '
+                '"%s" message: "%s"' % (code, message)
+            )
+        vSupportedClusterLevels = result['info']['clusterLevels']
+
+        self.logger.debug(
+            'VDSM SupportedClusterLevels [{levels}], '
+            'PACKAGE_VERSION [{pv}],'.format(
+                levels=vSupportedClusterLevels,
+                pv=result['info']['packages2']['vdsm']['version'],
+            )
         )
+
+        try:
+            v = max(
+                distutils.version.LooseVersion(vs).version
+                for vs in [
+                    x for x in eSupportedClusterLevels.split(',')
+                    if x in vSupportedClusterLevels
+                ]
+            )
+        except ValueError:
+            self.logger.debug('exception', exc_info=True)
+            raise RuntimeError(_(
+                'Failed to find a ClusterLevel supported '
+                'by both engine and VDSM'
+            ))
         engine_version = self._ovirtsdk_xml.params.Version(
             major=v[0],
             minor=v[1],


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

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

Reply via email to