From c0758f146273d915aebe632e4953c6d0f54d3cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Ribaud?= Date: Mon, 24 Jul 2023 17:35:52 +0200 Subject: [PATCH] Return HTTP response for delete_access_rule. In the original code, when ignore_missing parameter is set to False, no information is reported when either the share or the access is not found. However, after applying this patch, the HTTP response is returned to users, allowing them to verify whether the request completed successfully or not. If there are serious issues with the request clients, an exception will be raised to handle those situations appropriately. Change-Id: I925d943a00b4de198013336f5043753552255247 --- openstack/shared_file_system/v2/_proxy.py | 5 +++-- openstack/shared_file_system/v2/share_access_rule.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/openstack/shared_file_system/v2/_proxy.py b/openstack/shared_file_system/v2/_proxy.py index 157b1b7a5..4392c798f 100644 --- a/openstack/shared_file_system/v2/_proxy.py +++ b/openstack/shared_file_system/v2/_proxy.py @@ -816,10 +816,11 @@ class Proxy(proxy.Proxy): :param access_id: The id of the access rule to get :param share_id: The ID of the share - :rtype: ``None`` + :rtype: ``requests.models.Response`` HTTP response from internal + requests client """ res = self._get_resource(_share_access_rule.ShareAccessRule, access_id) - res.delete(self, share_id, ignore_missing=ignore_missing) + return res.delete(self, share_id, ignore_missing=ignore_missing) def share_group_snapshots(self, details=True, **query): """Lists all share group snapshots. diff --git a/openstack/shared_file_system/v2/share_access_rule.py b/openstack/shared_file_system/v2/share_access_rule.py index 48138c373..1983ad6dd 100644 --- a/openstack/shared_file_system/v2/share_access_rule.py +++ b/openstack/shared_file_system/v2/share_access_rule.py @@ -61,7 +61,7 @@ class ShareAccessRule(resource.Resource): if microversion is None: microversion = self._get_microversion(session, action=action) - session.post( + return session.post( url, json=body, headers=headers, microversion=microversion ) @@ -74,10 +74,12 @@ class ShareAccessRule(resource.Resource): ) def delete(self, session, share_id, ignore_missing=True): - body = {'deny_access': {'access_id': self.id}} - url = utils.urljoin('/shares', share_id, 'action') + body = {"deny_access": {"access_id": self.id}} + url = utils.urljoin("/shares", share_id, "action") + response = self._action(session, body, url) try: response = self._action(session, body, url) + self._translate_response(response) except exceptions.ResourceNotFound: if not ignore_missing: raise