]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
smbfs: fix invalid check for smbfs_used_ratio correctness
authorDmitry Guryanov <dguryanov@parallels.com>
Wed, 10 Jun 2015 20:01:55 +0000 (23:01 +0300)
committerDmitry Guryanov <dguryanov@parallels.com>
Tue, 30 Jun 2015 16:06:08 +0000 (19:06 +0300)
The check allowed to specify values greater than 1
because of a error in condition. So I've fixed the
condition and updated unit test, so it would catch
the bug.

Closes-Bug: #1469249

Change-Id: I34f4128a8a80ae57be5c0af90308d2d517022d8e

cinder/tests/unit/test_smbfs.py
cinder/volume/drivers/smbfs.py

index 05cf1f2a71999ce5ecbe64af0c70523816793e8b..028e9135217eb3aefc1eada6affb92dfe9450454 100644 (file)
@@ -132,6 +132,11 @@ class SmbFsTestCase(test.TestCase):
         fake_config.smbfs_used_ratio = -1
         self._test_setup(config=fake_config)
 
+    def test_setup_invalid_used_ratio2(self):
+        fake_config = copy.copy(self._FAKE_SMBFS_CONFIG)
+        fake_config.smbfs_used_ratio = 1.1
+        self._test_setup(config=fake_config)
+
     def _test_create_volume(self, volume_exists=False, volume_format=None):
         fake_method = mock.MagicMock()
         self._smbfs_driver.configuration = copy.copy(self._FAKE_SMBFS_CONFIG)
index e3321f0c3aa82307b1fd78093e3e32e43a47dc4a..fa6b3bfcd4cbd5ebe6330c343ce561d04a076fab 100644 (file)
@@ -156,8 +156,7 @@ class SmbfsDriver(remotefs_drv.RemoteFSSnapDriver):
             LOG.error(msg)
             raise exception.SmbfsException(msg)
 
-        if ((not self.configuration.smbfs_used_ratio > 0) and
-                (self.configuration.smbfs_used_ratio <= 1)):
+        if not 0 < self.configuration.smbfs_used_ratio <= 1:
             msg = _("SMBFS config 'smbfs_used_ratio' invalid.  Must be > 0 "
                     "and <= 1.0: %s") % self.configuration.smbfs_used_ratio
             LOG.error(msg)