From f905253b9443db1870c3d2b7b70e032bb089efa0 Mon Sep 17 00:00:00 2001 From: Adriano Rosso Date: Fri, 29 Sep 2017 10:29:48 -0300 Subject: [PATCH] NetApp E-series: Fix provisioned_capacity_gb Currently, NetApp E-series drivers (iSCSI and FC) are incorrectly reporting the total physical used size as the provisioned_capacity_gb. This patch fixes the calculation of this attribute by summing the user-visible capacity of all the volumes present in the backend and reporting the result as the provisioning_capacity_gb. Change-Id: I1471ecfffe340dafb1c95bac5eaff79cde650955 Closes-Bug: #1718739 --- .../tests/unit/volume/drivers/netapp/eseries/fakes.py | 2 +- .../volume/drivers/netapp/eseries/test_library.py | 9 ++++++++- cinder/volume/drivers/netapp/eseries/library.py | 11 ++++++++++- ...-provisioned-capacity-report-8c51fd1173c15dbf.yaml | 7 +++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-1718739-netapp-eseries-fix-provisioned-capacity-report-8c51fd1173c15dbf.yaml diff --git a/cinder/tests/unit/volume/drivers/netapp/eseries/fakes.py b/cinder/tests/unit/volume/drivers/netapp/eseries/fakes.py index d3eb51f42b2..2653b0e8c24 100644 --- a/cinder/tests/unit/volume/drivers/netapp/eseries/fakes.py +++ b/cinder/tests/unit/volume/drivers/netapp/eseries/fakes.py @@ -319,7 +319,7 @@ VOLUMES = [ }, "volumeRef": "0200000060080E50002998A00000945355C37C19", "status": "optimal", - "volumeGroupRef": "0400000060080E50002998A00000945255C37C14", + "volumeGroupRef": "fakevolgroupref", "currentManager": "070000000000000000000001", "preferredManager": "070000000000000000000001", "perms": { diff --git a/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py b/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py index 72a89db10a5..9a7731a012f 100644 --- a/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py +++ b/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py @@ -491,6 +491,7 @@ class NetAppEseriesLibraryTestCase(test.TestCase): def test_update_volume_stats_provisioning(self): """Validate pool capacity calculations""" fake_pool = copy.deepcopy(eseries_fake.STORAGE_POOL) + fake_eseries_volume = copy.deepcopy(eseries_fake.VOLUME) self.library._get_storage_pools = mock.Mock(return_value=[fake_pool]) self.mock_object(self.library, '_ssc_stats', {fake_pool["volumeGroupRef"]: { @@ -504,6 +505,11 @@ class NetAppEseriesLibraryTestCase(test.TestCase): total_gb = int(fake_pool['totalRaidedSpace']) / units.Gi used_gb = int(fake_pool['usedSpace']) / units.Gi free_gb = total_gb - used_gb + provisioned_gb = int(fake_eseries_volume['capacity']) * 10 / units.Gi + + # Testing with 10 fake volumes + self.library._client.list_volumes = mock.Mock( + return_value=[eseries_fake.VOLUME for _ in range(10)]) self.library._update_volume_stats() @@ -514,7 +520,8 @@ class NetAppEseriesLibraryTestCase(test.TestCase): self.assertEqual(over_subscription_ratio, pool_stats['max_over_subscription_ratio']) self.assertEqual(total_gb, pool_stats.get('total_capacity_gb')) - self.assertEqual(used_gb, pool_stats.get('provisioned_capacity_gb')) + self.assertEqual(provisioned_gb, + pool_stats.get('provisioned_capacity_gb')) self.assertEqual(free_gb, pool_stats.get('free_capacity_gb')) @ddt.data(False, True) diff --git a/cinder/volume/drivers/netapp/eseries/library.py b/cinder/volume/drivers/netapp/eseries/library.py index c66e8b3e513..a5beaea6101 100644 --- a/cinder/volume/drivers/netapp/eseries/library.py +++ b/cinder/volume/drivers/netapp/eseries/library.py @@ -1452,6 +1452,7 @@ class NetAppESeriesLibrary(object): data["driver_version"] = self.VERSION data["storage_protocol"] = self.driver_protocol data["pools"] = [] + storage_volumes = self._client.list_volumes() for storage_pool in self._get_storage_pools(): cinder_pool = {} @@ -1463,7 +1464,15 @@ class NetAppESeriesLibrary(object): self.configuration.max_over_subscription_ratio) tot_bytes = int(storage_pool.get("totalRaidedSpace", 0)) used_bytes = int(storage_pool.get("usedSpace", 0)) - cinder_pool["provisioned_capacity_gb"] = used_bytes / units.Gi + + provisioned_capacity = 0 + for volume in storage_volumes: + if (volume["volumeGroupRef"] == storage_pool.get('id') and + not volume['label'].startswith('repos_')): + provisioned_capacity += float(volume["capacity"]) + + cinder_pool["provisioned_capacity_gb"] = (provisioned_capacity / + units.Gi) cinder_pool["free_capacity_gb"] = ((tot_bytes - used_bytes) / units.Gi) cinder_pool["total_capacity_gb"] = tot_bytes / units.Gi diff --git a/releasenotes/notes/bug-1718739-netapp-eseries-fix-provisioned-capacity-report-8c51fd1173c15dbf.yaml b/releasenotes/notes/bug-1718739-netapp-eseries-fix-provisioned-capacity-report-8c51fd1173c15dbf.yaml new file mode 100644 index 00000000000..58e157a75b9 --- /dev/null +++ b/releasenotes/notes/bug-1718739-netapp-eseries-fix-provisioned-capacity-report-8c51fd1173c15dbf.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - The NetApp E-series driver has been fixed to correctly report + the "provisioned_capacity_gb". Now it sums the capacity of all + the volumes in the configured backend to get the correct value. + This bug fix affects all the protocols supported by the driver + (FC and iSCSI).