NetApp: Fix vserver create REST API

Vserver create API was failing since 'retention_period' is no longer
supported in POST (create) call. Fixed it by moving 'retention_period'
setting to PATCH (update) call.

Closes-bug: #2111918
Change-Id: I6d9fcd5a70673f0007b73d5c8e7536b118567088
Signed-off-by: Kiran Pawar <kinpaa@gmail.com>
This commit is contained in:
Kiran Pawar
2025-06-04 14:58:40 +00:00
parent 1d159679f2
commit 48cc585dbe
3 changed files with 29 additions and 5 deletions
@@ -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."""
@@ -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']),
@@ -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 <https://bugs.launchpad.net/manila/+bug/2111918>`_