From 3d1ba45a137775a3f8e3791afc2a22b0c66b7c6a Mon Sep 17 00:00:00 2001 From: wanghao Date: Mon, 1 Feb 2016 11:40:37 +0800 Subject: [PATCH] Make error response better for patching flavors In api v2.0, if updating flavor miss pool argument, zaqar will return bad request, "one of 'pool' needs to be specified". It's not clear enough since we only allow to update pool in API v2.0. Closes-Bug: #1540209 Change-Id: I8418f7b61065d3939bccf1d0cf262d7c8527d911 --- zaqar/transport/wsgi/v2_0/flavors.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/zaqar/transport/wsgi/v2_0/flavors.py b/zaqar/transport/wsgi/v2_0/flavors.py index 3c55f448d..1b56419a7 100644 --- a/zaqar/transport/wsgi/v2_0/flavors.py +++ b/zaqar/transport/wsgi/v2_0/flavors.py @@ -187,12 +187,11 @@ class Resource(object): @acl.enforce("flavors:update") def on_patch(self, request, response, project_id, flavor): - """Allows one to update a flavors's pool and/or capabilities. + """Allows one to update a flavors's pool. This method expects the user to submit a JSON object - containing at least one of: 'pool', 'capabilities'. If - none are found, the request is flagged as bad. There is also - strict format checking through the use of + containing 'pool'. If none is found, the request is flagged as bad. + There is also strict format checking through the use of jsonschema. Appropriate errors are returned in each case for badly formatted input. @@ -206,7 +205,7 @@ class Resource(object): if not any([(field in data) for field in EXPECT]): LOG.debug(u'PATCH flavor, bad params') raise wsgi_errors.HTTPBadRequestBody( - 'One of `pool` needs to be specified' + '`pool` needs to be specified' ) for field in EXPECT: