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 <Share: <id>>. To address this, we are introducing a patch that allows retrieving the full body response, not just the id resource. Change-Id: Ia15274e75aa5d3da04d861a64a2f437cd4a9a584
This commit is contained in:
parent
8e1b721fc3
commit
47b0ac7d59
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue