Placement client: always return body

In a few POST and PUT calls we didn't return the JSON body of the
response we got. By that we were just throwing away information we
already waited for.

This patch makes sure that if the HTTP response had a body we return it.

We leave one exception: PUT /resource_classes/ microversions 1.2 - 1.6.
Usage of that is strongly discouraged and starting from 1.7 the response
no longer has a body.

Change-Id: Ifa4db6edd4c656023039f7a68c09bf2cea508231
This commit is contained in:
Bence Romsics 2018-08-08 09:55:24 +02:00
parent ebbad5b995
commit 5aa2847367
2 changed files with 12 additions and 2 deletions

View File

@ -130,9 +130,10 @@ class PlacementAPIClient(object):
:param resource_provider: The resource provider. A dict with the name
(required) and the uuid (required).
:returns: The resource provider created.
"""
url = '/resource_providers'
self._post(url, resource_provider)
return self._post(url, resource_provider).json()
@_check_placement_api_available
def delete_resource_provider(self, resource_provider_uuid):
@ -353,9 +354,10 @@ class PlacementAPIClient(object):
:param resource_provider_uuid: UUID of the resource provider.
:param aggregates: aggregates to be associated to the resource
provider.
:returns: All aggregates associated with the resource provider.
"""
url = '/resource_providers/%s/aggregates' % resource_provider_uuid
self._put(url, aggregates)
return self._put(url, aggregates).json()
@_check_placement_api_available
def list_aggregates(self, resource_provider_uuid):

View File

@ -0,0 +1,8 @@
---
other:
- |
The ``create_resource_provider`` and ``associate_aggregates``
methods of ``PlacementAPIClient`` now return the parsed
body of the respective responses. Since these methods returned ``None``
previously this is unlikely to break anything. On the other hand callers
of these methods now have a chance to simplify their code.