From 623990df64092fe72a6473ac89fff1ba0d3aaec7 Mon Sep 17 00:00:00 2001 From: Goutham Pacha Ravi Date: Fri, 26 Aug 2016 21:47:44 -0400 Subject: [PATCH] NetApp cDOT: Fix reporting of replication capabilities Host level replication capability was added to the NetApp cDOT Block and File drivers through I87b92e76d0d5022e9be610b9e237b89417309c05. However, the replication capability was not being reported at the pool level. Add the field at pool level allowing for compatibility with volume types that may include the `replication_enabled` extra-spec. Change-Id: Ic735a527c609166884668c84c589da521769500b Closes-Bug: #1615451 --- .../drivers/netapp/dataontap/test_block_cmode.py | 13 ++++++++++++- .../drivers/netapp/dataontap/test_nfs_cmode.py | 14 +++++++++++++- .../volume/drivers/netapp/dataontap/block_cmode.py | 8 +++++++- .../volume/drivers/netapp/dataontap/nfs_cmode.py | 8 +++++++- ...ng-replication-capability-dca29f39b9fa7651.yaml | 5 +++++ 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1615451-NetApp-cDOT-fix-reporting-replication-capability-dca29f39b9fa7651.yaml diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py index 5ee7cee764a..cf595a297eb 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_block_cmode.py @@ -342,7 +342,8 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase): self.assertEqual(target_details_list[2], result) - def test_get_pool_stats(self): + @ddt.data([], ['target_1', 'target_2']) + def test_get_pool_stats(self, replication_backends): ssc = { 'vola': { @@ -364,6 +365,8 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase): mock_get_aggrs = self.mock_object(self.library.ssc_library, 'get_ssc_aggregates', mock.Mock(return_value=['aggr1'])) + self.mock_object(self.library, 'get_replication_backend_names', + mock.Mock(return_value=replication_backends)) self.library.reserved_percentage = 5 self.library.max_over_subscription_ratio = 10 @@ -414,7 +417,15 @@ class NetAppBlockStorageCmodeLibraryTestCase(test.TestCase): 'netapp_aggregate': 'aggr1', 'netapp_raid_type': 'raid_dp', 'netapp_disk_type': 'SSD', + 'replication_enabled': False, }] + if replication_backends: + expected[0].update({ + 'replication_enabled': True, + 'replication_count': len(replication_backends), + 'replication_targets': replication_backends, + 'replication_type': 'async', + }) self.assertEqual(expected, result) mock_get_ssc.assert_called_once_with() diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py index 7989cf9b5dd..9a26d0111da 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py @@ -143,7 +143,8 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase): self.assertEqual(1, mock_debug_log.call_count) self.assertEqual(expected_stats, self.driver._stats) - def test_get_pool_stats(self): + @ddt.data([], ['target_1', 'target_2']) + def test_get_pool_stats(self, replication_backends): self.driver.zapi_client = mock.Mock() ssc = { @@ -168,6 +169,9 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase): 'get_ssc_aggregates', mock.Mock(return_value=['aggr1'])) + self.mock_object(self.driver, 'get_replication_backend_names', + mock.Mock(return_value=replication_backends)) + total_capacity_gb = na_utils.round_down( fake.TOTAL_BYTES // units.Gi, '0.01') free_capacity_gb = na_utils.round_down( @@ -224,7 +228,15 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase): 'netapp_raid_type': 'raid_dp', 'netapp_disk_type': 'SSD', 'consistencygroup_support': True, + 'replication_enabled': False, }] + if replication_backends: + expected[0].update({ + 'replication_enabled': True, + 'replication_count': len(replication_backends), + 'replication_targets': replication_backends, + 'replication_type': 'async', + }) self.assertEqual(expected, result) mock_get_ssc.assert_called_once_with() diff --git a/cinder/volume/drivers/netapp/dataontap/block_cmode.py b/cinder/volume/drivers/netapp/dataontap/block_cmode.py index b97739b04f9..cf129ebe479 100644 --- a/cinder/volume/drivers/netapp/dataontap/block_cmode.py +++ b/cinder/volume/drivers/netapp/dataontap/block_cmode.py @@ -236,7 +236,9 @@ class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary, filter_function=filter_function, goodness_function=goodness_function) data['sparse_copy_volume'] = True - data.update(self.get_replication_backend_stats(self.configuration)) + + # Used for service state report + data['replication_enabled'] = self.replication_enabled self.zapi_client.provide_ems(self, self.driver_name, self.app_version) self._stats = data @@ -302,6 +304,10 @@ class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary, pool['filter_function'] = filter_function pool['goodness_function'] = goodness_function + # Add replication capabilities/stats + pool.update( + self.get_replication_backend_stats(self.configuration)) + pools.append(pool) return pools diff --git a/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py b/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py index 6e5471e0603..dfbd8cdc6cc 100644 --- a/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py +++ b/cinder/volume/drivers/netapp/dataontap/nfs_cmode.py @@ -201,7 +201,9 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver, filter_function=self.get_filter_function(), goodness_function=self.get_goodness_function()) data['sparse_copy_volume'] = True - data.update(self.get_replication_backend_stats(self.configuration)) + + # Used for service state report + data['replication_enabled'] = self.replication_enabled self._spawn_clean_cache_job() self.zapi_client.provide_ems(self, netapp_backend, self._app_version) @@ -258,6 +260,10 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver, pool['filter_function'] = filter_function pool['goodness_function'] = goodness_function + # Add replication capabilities/stats + pool.update( + self.get_replication_backend_stats(self.configuration)) + pools.append(pool) return pools diff --git a/releasenotes/notes/bug-1615451-NetApp-cDOT-fix-reporting-replication-capability-dca29f39b9fa7651.yaml b/releasenotes/notes/bug-1615451-NetApp-cDOT-fix-reporting-replication-capability-dca29f39b9fa7651.yaml new file mode 100644 index 00000000000..3e23e37bf80 --- /dev/null +++ b/releasenotes/notes/bug-1615451-NetApp-cDOT-fix-reporting-replication-capability-dca29f39b9fa7651.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - NetApp cDOT block and file drivers now report replication capability + at the pool level; and are hence compatible with using the + ``replication_enabled`` extra-spec in volume types.