nova/nova/tests
Chris Dent bd9f24b7aa Provide framework for setting placement error codes
The API-sig has a guideline[1] for including error codes in error
responses to help distinguish errors with the same status code
from one another. This change provides a simplest-thing-that-could-
possibly-work solution to make that go.

This solution comes about after a few different constraints and attempts:

* We would prefer to go on using the existing webob.exc exceptions, not
  make subclasses.
* We already have a special wrapper around our wsgi apps to deal with
  setting the json_error_formatter.
* Though webob allows custom Request and Response objects, it uses the
  default Response object as the parent of the HTTP exceptions.
* The Response object accepts kwargs, but only if they can be associated
  with known attributes on the class. Since we can't subclass...
* The json_error_formatter method is not passed the raw exception, but
  it does get the current WSGI environ
* The webob.exc classes take a 'comment' kwarg that is not used, but
  is also not passed to the json_error_formatter.

Therefore, when we raise an exception, we can set 'comment' to a code
and then assign that comment to a well known field in the environ and if
that environ is set in json_error_formatter, we can set 'code' in the
output.

This is done in a new microversion, 1.23. Every response gets a default
code 'placement.undefined_code' from 1.23 on. Future development will
add specific codes where required. This change adds a stub code for
inventory in use when doing a PUT to .../inventories but the name
may need improvement.

[1] http://specs.openstack.org/openstack/api-wg/guidelines/errors.html

Implements blueprint placement-api-error-handling

Change-Id: I9a833aa35d474caa35e640bbad6c436a3b16ac5e
2018-04-14 13:45:54 +01:00
..
functional Provide framework for setting placement error codes 2018-04-14 13:45:54 +01:00
live_migration/hooks Fix live migration grenade ceph setup 2017-10-26 17:53:15 -04:00
unit Merge "Sync xenapi and libvirt on what flags to pass e2fsck." 2018-04-14 02:23:01 +00:00
__init__.py
fixtures.py Add disabled field to CellMapping object 2018-03-20 15:38:29 +01:00
json_ref.py Nits from Ic3ab7d60e4ac12b767fe70bef97b327545a86e74 2017-11-28 15:55:45 +01:00
uuidsentinel.py Remove redundant str typecasting 2016-09-23 12:53:34 +05:30