From 19c3ed01762349d59f8090ebf5298e8117e72730 Mon Sep 17 00:00:00 2001 From: Maurice Schreiber Date: Mon, 18 Dec 2017 09:20:55 +0100 Subject: [PATCH] NetApp cDOT driver switch volume efficiency cDOT compression requires that deduplication is enabled. Reflect that in update_volume_efficiency_attributes method, which is now also used for create_volume. Closes-Bug: #1778022 Change-Id: I1aa05aa07b1cb64c44b1f654ee77b620b6c5e6d0 (cherry picked from commit 04aa4ba141d7a78ca5a924432cd2ddc7494a2c78) (cherry picked from commit d509dbb5e9532769b4e46b7c71433ab4099c808a) --- .../netapp/dataontap/client/client_cmode.py | 31 ++++++++++--------- .../dataontap/client/test_client_cmode.py | 7 +++++ ...ch-volume-efficiency-bd22733445d146f0.yaml | 7 +++++ 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/netapp-cdot-switch-volume-efficiency-bd22733445d146f0.yaml diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode.py b/manila/share/drivers/netapp/dataontap/client/client_cmode.py index 8d73708aee..06bc321769 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode.py @@ -1510,11 +1510,9 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): self.send_request('volume-create', api_args) - # cDOT compression requires that deduplication be enabled. - if dedup_enabled or compression_enabled: - self.enable_dedup(volume_name) - if compression_enabled: - self.enable_compression(volume_name) + self.update_volume_efficiency_attributes(volume_name, + dedup_enabled, + compression_enabled) if max_files is not None: self.set_volume_max_files(volume_name, max_files) @@ -1725,17 +1723,20 @@ class NetAppCmodeClient(client_base.NetAppBaseClient): """Update dedupe & compression attributes to match desired values.""" efficiency_status = self.get_volume_efficiency_status(volume_name) - if efficiency_status['compression'] != compression_enabled: - if compression_enabled: - self.enable_compression(volume_name) - else: - self.disable_compression(volume_name) + # cDOT compression requires dedup to be enabled + dedup_enabled = dedup_enabled or compression_enabled - if efficiency_status['dedupe'] != dedup_enabled: - if dedup_enabled: - self.enable_dedup(volume_name) - else: - self.disable_dedup(volume_name) + # enable/disable dedup if needed + if dedup_enabled and not efficiency_status['dedupe']: + self.enable_dedup(volume_name) + elif not dedup_enabled and efficiency_status['dedupe']: + self.disable_dedup(volume_name) + + # enable/disable compression if needed + if compression_enabled and not efficiency_status['compression']: + self.enable_compression(volume_name) + elif not compression_enabled and efficiency_status['compression']: + self.disable_compression(volume_name) @na_utils.trace def volume_exists(self, volume_name): diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py index 29dc93d299..447d2ace4e 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode.py @@ -2641,6 +2641,7 @@ class NetAppClientCmodeTestCase(test.TestCase): def test_create_volume(self): self.mock_object(self.client, 'send_request') + self.mock_object(self.client, 'update_volume_efficiency_attributes') self.client.create_volume( fake.SHARE_AGGREGATE_NAME, fake.SHARE_NAME, 100) @@ -2663,6 +2664,10 @@ class NetAppClientCmodeTestCase(test.TestCase): self.mock_object(self.client, 'enable_dedup') self.mock_object(self.client, 'enable_compression') self.mock_object(self.client, 'send_request') + self.mock_object( + self.client, + 'get_volume_efficiency_status', + mock.Mock(return_value={'dedupe': False, 'compression': False})) self.client.create_volume( fake.SHARE_AGGREGATE_NAME, fake.SHARE_NAME, 100, @@ -2697,6 +2702,7 @@ class NetAppClientCmodeTestCase(test.TestCase): def test_create_encrypted_volume(self): self.mock_object(self.client, 'send_request') + self.mock_object(self.client, 'update_volume_efficiency_attributes') self.client.features.add_feature('FLEXVOL_ENCRYPTION') self.client.create_volume( @@ -2717,6 +2723,7 @@ class NetAppClientCmodeTestCase(test.TestCase): def test_create_non_encrypted_volume(self): self.mock_object(self.client, 'send_request') + self.mock_object(self.client, 'update_volume_efficiency_attributes') self.client.features.add_feature('FLEXVOL_ENCRYPTION') self.client.create_volume( diff --git a/releasenotes/notes/netapp-cdot-switch-volume-efficiency-bd22733445d146f0.yaml b/releasenotes/notes/netapp-cdot-switch-volume-efficiency-bd22733445d146f0.yaml new file mode 100644 index 0000000000..e5c073e4ae --- /dev/null +++ b/releasenotes/notes/netapp-cdot-switch-volume-efficiency-bd22733445d146f0.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + NetApp driver volume efficiency settings now behave consistently: like on + volume creation now also modification, which is currently consumed by + manage and migration, will make sure that deduplication and compression + settings are applied correctly.