From: Vipin Balachandran Date: Fri, 16 Oct 2015 07:29:10 +0000 (+0530) Subject: VMware: Enforce min vCenter version X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f3bbe515344f076b605550ea6f85631c604dfc86;p=openstack-build%2Fcinder-build.git VMware: Enforce min vCenter version The VMDK driver deprecated vCenter versions less 5.1 in L release. This patch enforces the minimum required vCenter version for the VMDK driver. DocImpact The minimum required vCenter version for the VMDK driver is 5.1. Change-Id: I2ca0362623367d534b35124923947ee1e22c89fa --- diff --git a/cinder/tests/unit/test_vmware_vmdk.py b/cinder/tests/unit/test_vmware_vmdk.py index d8d4f276a..0412e6ce4 100644 --- a/cinder/tests/unit/test_vmware_vmdk.py +++ b/cinder/tests/unit/test_vmware_vmdk.py @@ -19,6 +19,7 @@ Test suite for VMware vCenter VMDK driver. from distutils import version as ver +import ddt import mock from mox3 import mox from oslo_utils import units @@ -78,6 +79,7 @@ class FakeObject(object): # TODO(vbala) Split test methods handling multiple cases into multiple methods, # each handling a specific case. +@ddt.ddt class VMwareVcVmdkDriverTestCase(test.TestCase): """Test class for VMwareVcVmdkDriver.""" @@ -1548,24 +1550,18 @@ class VMwareVcVmdkDriverTestCase(test.TestCase): version = self._driver._get_vc_version() self.assertEqual(ver.LooseVersion('6.0.1'), version) - @mock.patch('cinder.volume.drivers.vmware.vmdk.LOG') - def test_validate_vcenter_version(self, log): - vc_version = ver.LooseVersion('5.5') - self._driver._validate_vcenter_version(vc_version) - self.assertFalse(log.warning.called) - - @mock.patch('cinder.volume.drivers.vmware.vmdk.LOG') - def test_validate_vcenter_version_with_min_supported_version(self, log): - vc_version = self._driver.MIN_SUPPORTED_VC_VERSION - self._driver._validate_vcenter_version(vc_version) - self.assertFalse(log.warning.called) + @ddt.data('5.1', '5.5') + def test_validate_vcenter_version(self, version): + # vCenter versions 5.1 and above should pass validation. + self._driver._validate_vcenter_version(ver.LooseVersion(version)) - @mock.patch('cinder.volume.drivers.vmware.vmdk.LOG') def test_validate_vcenter_version_with_less_than_min_supported_version( - self, log): + self): vc_version = ver.LooseVersion('5.0') - self._driver._validate_vcenter_version(vc_version) - self.assertTrue(log.warning.called) + # Validation should fail for vCenter version less than 5.1. + self.assertRaises(exceptions.VMwareDriverException, + self._driver._validate_vcenter_version, + vc_version) @mock.patch('cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver.' '_validate_vcenter_version') diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index e331519ba..243a79cce 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -1712,13 +1712,10 @@ class VMwareVcVmdkDriver(driver.VolumeDriver): def _validate_vcenter_version(self, vc_version): if vc_version < self.MIN_SUPPORTED_VC_VERSION: - # TODO(vbala): enforce vCenter version in M release. - LOG.warning( - _LW('Running Cinder with a VMware vCenter version less than ' - '%(min_version)s is deprecated. The minimum required ' - 'version of vCenter server will be raised to ' - '%(min_version)s in the 8.0.0 release.'), - {'min_version': self.MIN_SUPPORTED_VC_VERSION}) + msg = _('Running Cinder with a VMware vCenter version less than ' + '%s is not allowed.') % self.MIN_SUPPORTED_VC_VERSION + LOG.error(msg) + raise exceptions.VMwareDriverException(message=msg) def do_setup(self, context): """Any initialization the volume driver does while starting."""