]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix for Pure drivers not checking full client version
authorPatrick East <patrick.east@purestorage.com>
Fri, 11 Mar 2016 18:27:50 +0000 (10:27 -0800)
committerPatrick East <patrick.east@purestorage.com>
Fri, 11 Mar 2016 20:24:08 +0000 (12:24 -0800)
We were only looking at major and minor versions… we needed to be
looking at the whole thing. This change allows for checking against
all three version parts, and for even differing schemes as time goes on.

Change-Id: Ib369d1d67fab5ba07d66c60f3fbc9c02afcbf3d4
Closes-Bug: #1556234

cinder/tests/unit/test_pure.py
cinder/volume/drivers/pure.py

index c6c94108631175066c18108a415da5186ac72eae..6a4f2812d27ad2c265d82c1fe3934811a7ff6369 100644 (file)
@@ -1890,7 +1890,11 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase):
             remvollist=[VOLUME_PURITY_NAME]
         )
 
-    @ddt.data(dict(version='1.5.0'), dict(version='2.0.0'))
+    @ddt.data(
+        dict(version='1.5.0'),
+        dict(version='2.0.0'),
+        dict(version='1.4.1'),
+    )
     @ddt.unpack
     def test_get_flasharray_verify_https(self, version):
         self.purestorage_module.VERSION = version
index ed39440ab5074dc23c5da7f171a99653acbcffcc..035c72c6f75d211c4c3dc5cc85fbcad74362c842 100644 (file)
@@ -961,15 +961,11 @@ class PureBaseVolumeDriver(san.SanDriver):
                                        "new_name": unmanaged_snap_name})
         self._rename_volume_object(snap_name, unmanaged_snap_name)
 
-    @staticmethod
-    def _get_flasharray(san_ip, api_token, rest_version=None,
+    def _get_flasharray(self, san_ip, api_token, rest_version=None,
                         verify_https=None, ssl_cert_path=None):
         # Older versions of the module (1.4.0) do not support setting ssl certs
         # TODO(patrickeast): In future releases drop support for 1.4.0
-        module_version = purestorage.VERSION.split('.')
-        major_version = int(module_version[0])
-        minor_version = int(module_version[1])
-        if major_version > 1 or (major_version == 1 and minor_version > 4):
+        if self._client_version_greater_than([1, 4, 0]):
             array = purestorage.FlashArray(san_ip,
                                            api_token=api_token,
                                            rest_version=rest_version,
@@ -995,6 +991,14 @@ class PureBaseVolumeDriver(san.SanDriver):
                    "api_version": array._rest_version})
         return array
 
+    @staticmethod
+    def _client_version_greater_than(version):
+        module_version = [int(v) for v in purestorage.VERSION.split('.')]
+        for limit_version, actual_version in zip(version, module_version):
+            if actual_version > limit_version:
+                return True
+        return False
+
     @staticmethod
     def _get_vol_name(volume):
         """Return the name of the volume Purity will use."""