Provide a hint when performing a volume action can't find the method

There is no CLI for the os-force_detach volume action API, and while
making a request for it with curl, I mistakenly used the Accept
header rather than the Content-Type header and got the unhelpful
error message:

  "There is no such action: None"

We can provide some simple details in the error message about
making sure the request body is correct and that the Content-Type
header is specified to help the user.

Change-Id: I00600c297e39c0dd097f9da80b1dccb38ee3d235
Closes-Bug: #1749983
This commit is contained in:
Matt Riedemann 2018-02-16 11:31:10 -05:00
parent 949309e06b
commit c100c8f188
1 changed files with 2 additions and 1 deletions

View File

@ -853,7 +853,8 @@ class Resource(wsgi.Application):
except (AttributeError, TypeError):
return Fault(webob.exc.HTTPNotFound())
except KeyError as ex:
msg = _("There is no such action: %s") % ex.args[0]
msg = (_("There is no such action: %s. Verify the request body "
"and Content-Type header and try again.") % ex.args[0])
return Fault(webob.exc.HTTPBadRequest(explanation=msg))
except exception.MalformedRequestBody:
msg = _("Malformed request body")