diff options
author | Jenkins <jenkins@review.openstack.org> | 2017-06-15 13:52:59 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2017-06-15 13:53:00 +0000 |
commit | df5b135053558714c67be1fb5673e20b5fbfe01b (patch) | |
tree | 7ecd3821b84ab75d8299e5ddbeee4b0a36dde0c2 /nova | |
parent | 07d8d7135e484a62d0b800f17e5323c8e2dc7939 (diff) | |
parent | d0957d72e25a4ca010df4807fd8224efe57df3f0 (diff) | |
download | nova-df5b135053558714c67be1fb5673e20b5fbfe01b.tar.gz |
Merge "[placement] Use util.extract_json in allocations handler"
Diffstat (limited to 'nova')
-rw-r--r-- | nova/api/openstack/placement/handlers/allocation.py | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/nova/api/openstack/placement/handlers/allocation.py b/nova/api/openstack/placement/handlers/allocation.py index da84ede877..607ae92452 100644 --- a/nova/api/openstack/placement/handlers/allocation.py +++ b/nova/api/openstack/placement/handlers/allocation.py @@ -13,7 +13,6 @@ import collections -import jsonschema from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import encodeutils @@ -93,24 +92,6 @@ def _allocations_dict(allocations, key_fetcher, resource_provider=None): return result -def _extract_allocations(body, schema): - """Extract allocation data from a JSON body.""" - try: - data = jsonutils.loads(body) - except ValueError as exc: - raise webob.exc.HTTPBadRequest( - _('Malformed JSON: %(error)s') % {'error': exc}, - json_formatter=util.json_error_formatter) - try: - jsonschema.validate(data, schema, - format_checker=jsonschema.FormatChecker()) - except jsonschema.ValidationError as exc: - raise webob.exc.HTTPBadRequest( - _('JSON does not validate: %(error)s') % {'error': exc}, - json_formatter=util.json_error_formatter) - return data - - def _serialize_allocations_for_consumer(allocations): """Turn a list of allocations into a dict by resource provider uuid. @@ -221,7 +202,7 @@ def list_for_resource_provider(req): def set_allocations(req): context = req.environ['placement.context'] consumer_uuid = util.wsgi_path_item(req.environ, 'consumer_uuid') - data = _extract_allocations(req.body, ALLOCATION_SCHEMA) + data = util.extract_json(req.body, ALLOCATION_SCHEMA) allocation_data = data['allocations'] # If the body includes an allocation for a resource provider |