diff --git a/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py b/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py index fe0005c5fb..b480302042 100644 --- a/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py +++ b/manila/share/drivers/netapp/dataontap/client/client_cmode_rest.py @@ -4394,11 +4394,20 @@ class NetAppRestClient(object): for aggr_name in aggregate_names: body['aggregates'].append({'name': aggr_name}) - if delete_retention_hours != 0: - body['retention_period'] = delete_retention_hours - self.send_request('/svm/svms', 'post', body=body) + if delete_retention_hours != 0: + try: + svm_uuid = self._get_unique_svm_by_name(vserver_name) + body = { + 'retention_period': delete_retention_hours + } + self.send_request(f'/svm/svms/{svm_uuid}', 'patch', + body=body) + except netapp_api.api.NaApiError: + LOG.warning('Failed to modify retention period for vserver ' + '%(server)s.', {'server': vserver_name}) + @na_utils.trace def _modify_security_cert(self, vserver_name, security_cert_expire_days): """Create new security certificate with given expire days.""" diff --git a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py index ce3185dfbc..626e9a147c 100644 --- a/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py +++ b/manila/tests/share/drivers/netapp/dataontap/client/test_client_cmode_rest.py @@ -5987,7 +5987,9 @@ class NetAppRestCmodeClientTestCase(test.TestCase): def test__create_vserver(self): mock_sr = self.mock_object(self.client, 'send_request') - body = { + self.mock_object(self.client, '_get_unique_svm_by_name', + mock.Mock(return_value=fake.FAKE_UUID)) + body_post = { 'name': fake.VSERVER_NAME, 'nsswitch.namemap': fake.FAKE_SERVER_SWITCH_NAME, 'subtype': fake.FAKE_SUBTYPE, @@ -5995,6 +5997,9 @@ class NetAppRestCmodeClientTestCase(test.TestCase): 'aggregates': [{ 'name': fake.SHARE_AGGREGATE_NAME }], + } + + body_patch = { 'retention_period': fake.DELETE_RETENTION_HOURS, } @@ -6005,7 +6010,10 @@ class NetAppRestCmodeClientTestCase(test.TestCase): fake.FAKE_SERVER_SWITCH_NAME, fake.FAKE_SUBTYPE) - mock_sr.assert_called_once_with('/svm/svms', 'post', body=body) + mock_sr.assert_has_calls([ + mock.call('/svm/svms', 'post', body=body_post), + mock.call(f'/svm/svms/{fake.FAKE_UUID}', 'patch', body=body_patch) + ]) @ddt.data((f'/name-services/dns/{fake.FAKE_UUID}', 'patch', ['fake_domain'], ['fake_ip']), diff --git a/releasenotes/notes/bug-2111918-netapp-fix-rentention-period-rest-api-e73b358ccc6e7b37.yaml b/releasenotes/notes/bug-2111918-netapp-fix-rentention-period-rest-api-e73b358ccc6e7b37.yaml new file mode 100644 index 0000000000..494f79b877 --- /dev/null +++ b/releasenotes/notes/bug-2111918-netapp-fix-rentention-period-rest-api-e73b358ccc6e7b37.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed an issue while creating shares due to an undesired retention period + parameter in NetApp ONTAP driver. Fixed this by moving retention_period + in PATCH instead of POST api request. For more details, please check + `Launchpad bug #2111918 `_