From 632f939b9884cc917650f83e50930fd702a05119 Mon Sep 17 00:00:00 2001 From: Anton Arefiev Date: Mon, 15 Dec 2014 12:33:38 +0200 Subject: [PATCH] Delete default volume size 100M in drivers There is check: if volume size == 0 we set default value to 100M, it uses only in tests and it's little bit confusing.Use code only for tests in drivers is bad practice. Also the create volume flow already won't let user to create a volume with size 0. So it was decided to remove this check. Change-Id: I620ae8fff4634c60a02329f22d1a0343b27aa955 --- cinder/tests/test_gpfs.py | 1 - cinder/tests/test_scality.py | 4 ++-- cinder/volume/drivers/ibm/gpfs.py | 3 --- cinder/volume/drivers/lvm.py | 2 -- cinder/volume/drivers/rbd.py | 5 +---- cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py | 5 +---- cinder/volume/drivers/san/solaris.py | 5 +---- cinder/volume/drivers/scality.py | 2 -- 8 files changed, 5 insertions(+), 22 deletions(-) diff --git a/cinder/tests/test_gpfs.py b/cinder/tests/test_gpfs.py index 54e760b94..470b2e00f 100644 --- a/cinder/tests/test_gpfs.py +++ b/cinder/tests/test_gpfs.py @@ -96,7 +96,6 @@ class GPFSDriverTestCase(test.TestCase): self.assertFalse(gpfs._different(None)) def test_sizestr(self): - self.assertEqual(gpfs._sizestr('0'), '100M') self.assertEqual(gpfs._sizestr('10'), '10G') @patch('cinder.utils.execute') diff --git a/cinder/tests/test_scality.py b/cinder/tests/test_scality.py index b9d1529b9..657ff9aac 100644 --- a/cinder/tests/test_scality.py +++ b/cinder/tests/test_scality.py @@ -43,7 +43,7 @@ class ScalityDriverTestCase(test.TestCase): TEST_VOLDIR = 'volumes' TEST_VOLNAME = 'volume_name' - TEST_VOLSIZE = '0' + TEST_VOLSIZE = '1' TEST_VOLUME = { 'name': TEST_VOLNAME, 'size': TEST_VOLSIZE @@ -183,7 +183,7 @@ class ScalityDriverTestCase(test.TestCase): self.TEST_VOLNAME)) self.assertTrue(os.path.isfile(self.TEST_VOLPATH)) self.assertEqual(os.stat(self.TEST_VOLPATH).st_size, - 100 * units.Mi) + 1 * units.Gi) def test_delete_volume(self): """Expected behaviour for delete_volume.""" diff --git a/cinder/volume/drivers/ibm/gpfs.py b/cinder/volume/drivers/ibm/gpfs.py index 4d455f030..9396612d1 100644 --- a/cinder/volume/drivers/ibm/gpfs.py +++ b/cinder/volume/drivers/ibm/gpfs.py @@ -97,9 +97,6 @@ def _same_filesystem(path1, path2): def _sizestr(size_in_g): """Convert the specified size into a string value.""" - if int(size_in_g) == 0: - # return 100M size on zero input for testing - return '100M' return '%sG' % size_in_g diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 95c885902..3bd67b94d 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -115,8 +115,6 @@ class LVMVolumeDriver(driver.VolumeDriver): data=exception_message) def _sizestr(self, size_in_g): - if int(size_in_g) == 0: - return '100m' return '%sg' % size_in_g def _volume_not_present(self, volume_name): diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 3c7dda251..703d14ff3 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -485,10 +485,7 @@ class RBDDriver(driver.VolumeDriver): def create_volume(self, volume): """Creates a logical volume.""" - if int(volume['size']) == 0: - size = 100 * units.Mi - else: - size = int(volume['size']) * units.Gi + size = int(volume['size']) * units.Gi LOG.debug("creating volume '%s'" % (volume['name'])) diff --git a/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py b/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py index c75e0983a..6a105174d 100644 --- a/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py +++ b/cinder/volume/drivers/san/hp/hp_lefthand_cliq_proxy.py @@ -274,10 +274,7 @@ class HPLeftHandCLIQProxy(SanISCSIDriver): cliq_args['thinProvision'] = '0' cliq_args['volumeName'] = volume['name'] - if int(volume['size']) == 0: - cliq_args['size'] = '100MB' - else: - cliq_args['size'] = '%sGB' % volume['size'] + cliq_args['size'] = '%sGB' % volume['size'] self._cliq_run_xml("createVolume", cliq_args) diff --git a/cinder/volume/drivers/san/solaris.py b/cinder/volume/drivers/san/solaris.py index 74ef541cd..2cb1d963a 100644 --- a/cinder/volume/drivers/san/solaris.py +++ b/cinder/volume/drivers/san/solaris.py @@ -128,10 +128,7 @@ class SolarisISCSIDriver(SanISCSIDriver): def create_volume(self, volume): """Creates a volume.""" - if int(volume['size']) == 0: - sizestr = '100M' - else: - sizestr = '%sG' % volume['size'] + sizestr = '%sG' % volume['size'] zfs_poolname = self._build_zfs_poolname(volume) diff --git a/cinder/volume/drivers/scality.py b/cinder/volume/drivers/scality.py index 583fa3f4a..82f2c1bac 100644 --- a/cinder/volume/drivers/scality.py +++ b/cinder/volume/drivers/scality.py @@ -114,8 +114,6 @@ class ScalityDriver(driver.VolumeDriver): raise exception.VolumeBackendAPIException(data=msg) def _size_bytes(self, size_in_g): - if int(size_in_g) == 0: - return 100 * units.Mi return int(size_in_g) * units.Gi def _create_file(self, path, size): -- 2.45.2