NetApp ONTAP: Fix delete-share for vsadmin users

qos- APIs are unavailable to vsadmin users. Fix the
code in the delete share flow to prevent failing on
being unable to execute the qos-get-iter call.

Change-Id: If9ce7c840fc968824d53002eaaea082e28631178
Closes-Bug: 1765420
(cherry picked from commit 4de799677d)
This commit is contained in:
Goutham Pacha Ravi 2018-04-09 19:00:57 -04:00
parent 8ac7bf43e7
commit 3d6ed0c33e
3 changed files with 35 additions and 2 deletions

View File

@ -3669,8 +3669,19 @@ class NetAppCmodeClient(client_base.NetAppBaseClient):
},
},
}
result = self.send_request('qos-policy-group-get-iter', api_args,
False)
try:
result = self.send_request('qos-policy-group-get-iter',
api_args,
False)
except netapp_api.NaApiError as e:
if e.code == netapp_api.EAPINOTFOUND:
msg = _("Configured ONTAP login user cannot retrieve "
"QoS policies.")
LOG.error(msg)
raise exception.NetAppException(msg)
else:
raise
if not self._has_records(result):
msg = _("No QoS policy group found with name %s.")
raise exception.NetAppException(msg % qos_policy_group_name)

View File

@ -6222,6 +6222,24 @@ class NetAppClientCmodeTestCase(test.TestCase):
self.assertIs(True, policy_exists)
def test_qos_policy_group_get_no_permissions_to_execute_zapi(self):
naapi_error = self._mock_api_error(code=netapp_api.EAPINOTFOUND,
message='13005:Unable to find API')
self.mock_object(self.client, 'send_request', naapi_error)
self.assertRaises(exception.NetAppException,
self.client.qos_policy_group_get,
'possibly-valid-qos-policy')
def test_qos_policy_group_get_other_zapi_errors(self):
naapi_error = self._mock_api_error(code=netapp_api.EINTERNALERROR,
message='13114:Internal error')
self.mock_object(self.client, 'send_request', naapi_error)
self.assertRaises(netapp_api.NaApiError,
self.client.qos_policy_group_get,
'possibly-valid-qos-policy')
def test_qos_policy_group_get_none_found(self):
no_records_response = netapp_api.NaElement(fake.NO_RECORDS_RESPONSE)
self.mock_object(self.client, 'send_request',

View File

@ -0,0 +1,4 @@
---
fixes:
- The `Launchpad bug 1765420 <https://bugs.launchpad.net/manila/+bug/1765420>`_
that affected the NetApp ONTAP driver during share deletion has been fixed.