From 018ba6302b0f5b909e9f32f44a14c21313a2663e Mon Sep 17 00:00:00 2001 From: KIYOHIRO ADACHI Date: Tue, 26 Nov 2013 15:54:17 +0900 Subject: [PATCH] Fix _update_volume_stats typos Fix _update_volume_stats typos in 'cinder/volume/driver.py' and 'cinder/volume/drivers/eqlx.py'. '_update_volume_status' to '_update_volume_stats' Change-Id: I0642bdb911ca72517ed655f795e0055f4c4654b8 Closes-Bug: #1254978 --- cinder/tests/test_eqlx.py | 16 ++++++++++++++-- cinder/tests/test_volume.py | 28 ++++++++++++++++++++++++++++ cinder/volume/driver.py | 6 +++--- cinder/volume/drivers/eqlx.py | 6 +++--- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/cinder/tests/test_eqlx.py b/cinder/tests/test_eqlx.py index 433989374..c2306e6a7 100644 --- a/cinder/tests/test_eqlx.py +++ b/cinder/tests/test_eqlx.py @@ -217,17 +217,29 @@ class DellEQLSanISCSIDriverTestCase(test.TestCase): self.driver.do_setup(self._context) self.assertEqual(fake_group_ip, self.driver._group_ip) - def test_update_volume_status(self): + def test_update_volume_stats(self): self.driver._eql_execute = self.mox.\ CreateMock(self.driver._eql_execute) self.driver._eql_execute('pool', 'select', self.configuration.eqlx_pool, 'show').\ AndReturn(['TotalCapacity: 111GB', 'FreeSpace: 11GB']) self.mox.ReplayAll() - self.driver._update_volume_status() + self.driver._update_volume_stats() self.assertEqual(self.driver._stats['total_capacity_gb'], 111.0) self.assertEqual(self.driver._stats['free_capacity_gb'], 11.0) + def test_update_volume_stats2(self): + self.driver._eql_execute = self.mox.\ + CreateMock(self.driver._eql_execute) + self.driver._eql_execute('pool', 'select', + self.configuration.eqlx_pool, 'show').\ + AndReturn(['TotalCapacity: 111GB', 'FreeSpace: 11GB']) + self.mox.ReplayAll() + stats = self.driver.get_volume_stats(refresh=True) + self.assertEqual(stats['total_capacity_gb'], float('111.0')) + self.assertEqual(stats['free_capacity_gb'], float('11.0')) + self.assertEqual(stats['vendor_name'], 'Dell') + def test_get_space_in_gb(self): self.assertEqual(self.driver._get_space_in_gb('123.0GB'), 123.0) self.assertEqual(self.driver._get_space_in_gb('123.0TB'), 123.0 * 1024) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index bbdea1d80..b0daff791 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -2378,6 +2378,34 @@ class ISERTestCase(ISCSITestCase): self.configuration.iser_ip_address = '0.0.0.0' self.configuration.iser_port = 3260 + def test_get_volume_stats(self): + def _fake_get_all_volume_groups(obj, vg_name=None, no_suffix=True): + return [{'name': 'cinder-volumes', + 'size': '5.52', + 'available': '0.52', + 'lv_count': '2', + 'uuid': 'vR1JU3-FAKE-C4A9-PQFh-Mctm-9FwA-Xwzc1m'}] + + self.stubs.Set(brick_lvm.LVM, + 'get_all_volume_groups', + _fake_get_all_volume_groups) + self.volume.driver.vg = brick_lvm.LVM('cinder-volumes', 'sudo') + + stats = self.volume.driver.get_volume_stats(refresh=True) + + self.assertEqual(stats['total_capacity_gb'], float('5.52')) + self.assertEqual(stats['free_capacity_gb'], float('0.52')) + self.assertEqual(stats['storage_protocol'], 'iSER') + + def test_get_volume_stats2(self): + iser_driver = self.base_driver(configuration=self.configuration) + + stats = iser_driver.get_volume_stats(refresh=True) + + self.assertEqual(stats['total_capacity_gb'], 'infinite') + self.assertEqual(stats['free_capacity_gb'], 'infinite') + self.assertEqual(stats['storage_protocol'], 'iSER') + class FibreChannelTestCase(DriverTestCase): """Test Case for FibreChannelDriver.""" diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index ab9c27511..049fd7a71 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -795,10 +795,10 @@ class ISERDriver(ISCSIDriver): 'data': iser_properties } - def _update_volume_status(self): - """Retrieve status info from volume group.""" + def _update_volume_stats(self): + """Retrieve stats info from volume group.""" - LOG.debug(_("Updating volume status")) + LOG.debug(_("Updating volume stats")) data = {} backend_name = self.configuration.safe_get('volume_backend_name') data["volume_backend_name"] = backend_name or 'Generic_iSER' diff --git a/cinder/volume/drivers/eqlx.py b/cinder/volume/drivers/eqlx.py index 92cdef642..75cca0f46 100644 --- a/cinder/volume/drivers/eqlx.py +++ b/cinder/volume/drivers/eqlx.py @@ -241,10 +241,10 @@ class DellEQLSanISCSIDriver(SanISCSIDriver): part = 'TB' return scale * float(val.partition(part)[0]) - def _update_volume_status(self): - """Retrieve status info from volume group.""" + def _update_volume_stats(self): + """Retrieve stats info from eqlx group.""" - LOG.debug(_("Updating volume status")) + LOG.debug(_("Updating volume stats")) data = {} backend_name = "eqlx" if self.configuration: -- 2.45.2