nova/nova
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
..
api Provide framework for setting placement error codes 2018-04-14 13:45:54 +01:00
cells Add instance action record for snapshot instances 2017-12-11 17:46:38 +08:00
cmd Merge "Marker reset option for nova-manage map_instances" 2018-04-11 17:57:04 +00:00
common
compute Merge "Add host to API and Conductor" 2018-04-14 00:47:10 +00:00
conductor Merge "Add host to API and Conductor" 2018-04-14 00:47:10 +00:00
conf Merge "Expose shutdown retry interval as config setting" 2018-04-11 16:41:42 +00:00
console trivial: fix a comment typo 2018-04-11 18:05:46 +08:00
consoleauth
db Merge "conf: Remove 'db_driver' config opt" 2018-04-09 11:46:46 +00:00
hacking Fix N332 api_version decorator hacking check 2018-03-29 10:27:30 -05:00
image Workaround glanceclient bug when CONF.glance.api_servers not set 2018-02-08 09:06:48 -05:00
ipv6
keymgr
locale Imported Translations from Zanata 2018-04-11 06:17:52 +00:00
network Merge "Rename network.utils to network.linux_utils." 2018-04-13 22:47:05 +00:00
notifications Handle EndpointNotFound when building image_ref_url in notifications 2018-03-20 17:22:50 -04:00
objects Merge "Add host field to InstanceActionEvent" 2018-04-13 18:51:45 +00:00
pci remove unnecessary conf imports 2018-03-09 14:30:10 -05:00
policies trivial: Fix few policy doc 2018-02-01 03:04:00 +00:00
privsep Move xenapi disk resizing to privsep. 2018-04-13 07:09:58 +10:00
scheduler Merge "Skip placement on rebuild in same host" 2018-04-13 22:47:45 +00:00
servicegroup
tests Provide framework for setting placement error codes 2018-04-14 13:45:54 +01:00
virt Merge "Sync xenapi and libvirt on what flags to pass e2fsck." 2018-04-14 02:23:01 +00:00
vnc
volume Log a more useful error when cinder auth isn't configured 2018-04-06 14:52:13 -04:00
__init__.py
availability_zones.py
baserpc.py
block_device.py Add uuid column to BlockDeviceMapping 2017-12-17 14:28:35 +00:00
cache_utils.py
config.py
context.py Merge "trivial: Resolve 'oslo.context' deprecation warnings" 2018-03-23 21:47:12 +00:00
crypto.py crypto: Remove unused functions 2018-03-08 10:24:40 +00:00
debugger.py
exception.py Merge "Add __repr__ for NovaException" 2018-04-05 18:49:00 +00:00
exception_wrapper.py
filters.py
hooks.py
i18n.py correct referenced url in comments 2018-01-18 09:16:37 +08:00
loadables.py
manager.py conf: Remove 'db_driver' config opt 2018-03-16 17:23:16 +00:00
policy.py
profiler.py
quota.py Remove unnecessary variables 2018-02-08 10:15:53 +09:00
rc_fields.py Make ResourceClass.normalize_name handle sharp S 2018-04-10 12:24:40 -05:00
rpc.py Remove useless run_periodic_tasks call in ClientRouter 2018-03-20 23:54:21 +00:00
safe_utils.py
service.py Merge "Refactor WSGI apps and utils to limit imports" 2018-03-08 15:16:56 +00:00
service_auth.py Fix NoneType error when [service_user] is misconfigured 2017-11-28 12:22:30 -06:00
test.py tests: fixes mock autospec usage 2018-03-28 00:02:31 -07:00
utils.py Merge "Refactor WSGI apps and utils to limit imports" 2018-03-08 15:16:56 +00:00
version.py
weights.py
wsgi.py Refactor WSGI apps and utils to limit imports 2018-03-06 22:05:12 +00:00