From 47b0ac7d593acce86e5cfae58dcab37abc45ff24 Mon Sep 17 00:00:00 2001 From: lkuchlan Date: Wed, 2 Aug 2023 15:50:17 +0300 Subject: [PATCH] Enable the option to return the response body As part of our efforts to enhance automation and CI for Manila, we have begun developing code in the Tobiko tool to support the Manila client. During create/get operations, we have observed that the returned body contains solely the resource id in the format >. To address this, we are introducing a patch that allows retrieving the full body response, not just the id resource. Change-Id: Ia15274e75aa5d3da04d861a64a2f437cd4a9a584 --- manilaclient/base.py | 4 +++- manilaclient/v2/shares.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/manilaclient/base.py b/manilaclient/base.py index 4166c58c1..72cb7da32 100644 --- a/manilaclient/base.py +++ b/manilaclient/base.py @@ -168,9 +168,11 @@ class Manager(utils.HookableMixin): except UnicodeEncodeError: pass - def _get(self, url, response_key=None): + def _get(self, url, response_key, return_raw=False): resp, body = self.api.client.get(url) if response_key: + if return_raw: + return body[response_key] return self.resource_class(self, body[response_key], loaded=True) else: return self.resource_class(self, body, loaded=True) diff --git a/manilaclient/v2/shares.py b/manilaclient/v2/shares.py index c0bf90625..71c493904 100644 --- a/manilaclient/v2/shares.py +++ b/manilaclient/v2/shares.py @@ -125,7 +125,7 @@ class ShareManager(base.MetadataCapableManager): def create(self, share_proto, size, snapshot_id=None, name=None, description=None, metadata=None, share_network=None, share_type=None, is_public=False, availability_zone=None, - share_group_id=None, scheduler_hints=None): + share_group_id=None, scheduler_hints=None, return_raw=False): """Create a share. :param share_proto: text - share protocol for new share available @@ -164,7 +164,8 @@ class ShareManager(base.MetadataCapableManager): if share_group_id: body['share_group_id'] = share_group_id - return self._create('/shares', {'share': body}, 'share') + return self._create('/shares', {'share': body}, 'share', + return_raw=return_raw) @api_versions.wraps("2.29") @api_versions.experimental_api @@ -319,14 +320,15 @@ class ShareManager(base.MetadataCapableManager): info = {'snapshot_id': snapshot_id} return self._action('revert', share, info=info) - def get(self, share): + def get(self, share, return_raw=False): """Get a share. :param share: either share object or text with its ID. :rtype: :class:`Share` """ share_id = base.getid(share) - return self._get("/shares/%s" % share_id, "share") + return self._get("/shares/%s" % share_id, "share", + return_raw=return_raw) def update(self, share, **kwargs): """Updates a share.