From b75d26f9f3a15f00e2a9605e23752b30cab583e6 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Tue, 13 May 2014 01:01:55 -0400 Subject: [PATCH] Convert SolidFire Capacity response to GiB This patch fixes the reported free_capacity_gb response in the SolidFire update_cluster_status method. The initial patch fixed the free_capacity conversion, however omitted the same fix that was needed for the free_space calculation. Closes Bug: #1284452 Change-Id: If034957764911ec92a6d7e603d0510325018db6d --- cinder/tests/test_solidfire.py | 12 ++++++++++-- cinder/volume/drivers/solidfire.py | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cinder/tests/test_solidfire.py b/cinder/tests/test_solidfire.py index c4efcfe7d..87bbd2edc 100644 --- a/cinder/tests/test_solidfire.py +++ b/cinder/tests/test_solidfire.py @@ -60,8 +60,8 @@ class SolidFireVolumeTestCase(test.TestCase): if method is 'GetClusterCapacity' and version == '1.0': LOG.info('Called Fake GetClusterCapacity...') data = {'result': - {'clusterCapacity': {'maxProvisionedSpace': 99999999, - 'usedSpace': 999, + {'clusterCapacity': {'maxProvisionedSpace': 107374182400, + 'usedSpace': 1073741824, 'compressionPercent': 100, 'deDuplicationPercent': 100, 'thinProvisioningPercent': 100}}} @@ -552,3 +552,11 @@ class SolidFireVolumeTestCase(test.TestCase): self.assertTrue(sfv.retype(self.ctxt, testvol, test_type, diff, host)) + + def test_update_cluster_status(self): + self.stubs.Set(SolidFireDriver, '_issue_api_request', + self.fake_issue_api_request) + sfv = SolidFireDriver(configuration=self.configuration) + sfv._update_cluster_status() + self.assertEqual(sfv.cluster_stats['free_capacity_gb'], 99.0) + self.assertEqual(sfv.cluster_stats['total_capacity_gb'], 100.0) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 4952cdb76..33f1511e0 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -681,7 +681,8 @@ class SolidFireDriver(SanISCSIDriver): data["driver_version"] = self.VERSION data["storage_protocol"] = 'iSCSI' - data['total_capacity_gb'] = results['maxProvisionedSpace'] + data['total_capacity_gb'] =\ + float(results['maxProvisionedSpace'] / units.GiB) data['free_capacity_gb'] = float(free_capacity / units.GiB) data['reserved_percentage'] = self.configuration.reserved_percentage -- 2.45.2