]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
VMware: Enforce min vCenter version
authorVipin Balachandran <vbala@vmware.com>
Fri, 16 Oct 2015 07:29:10 +0000 (12:59 +0530)
committerVipin Balachandran <vbala@vmware.com>
Tue, 20 Oct 2015 05:52:07 +0000 (11:22 +0530)
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

cinder/tests/unit/test_vmware_vmdk.py
cinder/volume/drivers/vmware/vmdk.py

index d8d4f276ad5f7fb986b699cea91c5ba717fe194a..0412e6ce4d19e6165fa8f16a84dc953959c8a7f9 100644 (file)
@@ -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')
index e331519babd8805475ed9623d86c6ded0cfd062f..243a79cce0e0ef4cb45fb115355eeeaf6955f738 100644 (file)
@@ -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."""