From: Patrick East Date: Fri, 11 Mar 2016 18:27:50 +0000 (-0800) Subject: Fix for Pure drivers not checking full client version X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7acd29c095df155af8b13f8863339bc68dd93afb;p=openstack-build%2Fcinder-build.git Fix for Pure drivers not checking full client version 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 --- diff --git a/cinder/tests/unit/test_pure.py b/cinder/tests/unit/test_pure.py index c6c941086..6a4f2812d 100644 --- a/cinder/tests/unit/test_pure.py +++ b/cinder/tests/unit/test_pure.py @@ -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 diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index ed39440ab..035c72c6f 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -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."""