Merge "placement: Fix HTTP error generation" into stable/pike

This commit is contained in:
Zuul 2018-06-25 19:27:26 +00:00 committed by Gerrit Code Review
commit 02fcd57260
2 changed files with 8 additions and 12 deletions

View File

@ -412,7 +412,7 @@ def delete_inventories(req):
except exception.InventoryInUse as ex:
# NOTE(mriedem): This message cannot change without impacting the
# nova.scheduler.client.report._RE_INV_IN_USE regex.
raise webob.exc.HTTPConflict(explanation=ex.format_message())
raise webob.exc.HTTPConflict(ex.format_message())
response = req.response
response.status = 204

View File

@ -126,8 +126,7 @@ def get_trait(req):
try:
objects.Trait.get_by_name(context, name)
except exception.TraitNotFound as ex:
raise webob.exc.HTTPNotFound(
explanation=ex.format_message())
raise webob.exc.HTTPNotFound(ex.format_message())
req.response.status = 204
req.response.content_type = None
@ -144,14 +143,11 @@ def delete_trait(req):
trait = objects.Trait.get_by_name(context, name)
trait.destroy()
except exception.TraitNotFound as ex:
raise webob.exc.HTTPNotFound(
explanation=ex.format_message())
raise webob.exc.HTTPNotFound(ex.format_message())
except exception.TraitCannotDeleteStandard as ex:
raise webob.exc.HTTPBadRequest(
explanation=ex.format_message())
raise webob.exc.HTTPBadRequest(ex.format_message())
except exception.TraitInUse as ex:
raise webob.exc.HTTPConflict(
explanation=ex.format_message())
raise webob.exc.HTTPConflict(ex.format_message())
req.response.status = 204
req.response.content_type = None
@ -178,8 +174,8 @@ def list_traits(req):
if 'associated' in req.GET:
if req.GET['associated'].lower() not in ['true', 'false']:
raise webob.exc.HTTPBadRequest(
explanation=_('The query parameter "associated" only accepts '
'"true" or "false"'))
_('The query parameter "associated" only accepts '
'"true" or "false"'))
filters['associated'] = (
True if req.GET['associated'].lower() == 'true' else False)
@ -258,7 +254,7 @@ def delete_traits_for_resource_provider(req):
try:
resource_provider.set_traits(objects.TraitList(objects=[]))
except exception.ConcurrentUpdateDetected as e:
raise webob.exc.HTTPConflict(explanation=e.format_message())
raise webob.exc.HTTPConflict(e.format_message())
req.response.status = 204
req.response.content_type = None