Add informative messages to the 404 error response from
inventory.py and usage.py
This change also includes adding/altering existing Gabbi tests
for 404 response and add resonse_strings validation checks for
that.
Change-Id: Ica46a5479dec06b035f8b43d6738e9d124f6ae37
Related-Bug: #
1634115
_('Unable to delete inventory of class %(class)s: %(error)s') %
{'class': resource_class, 'error': exc},
json_formatter=util.json_error_formatter)
+ except exception.NotFound as exc:
+ raise webob.exc.HTTPNotFound(
+ _('No inventory of class %(class)s found for delete: %(error)s') %
+ {'class': resource_class, 'error': exc},
+ json_formatter=util.json_error_formatter)
response = req.response
response.status = 204
"""
context = req.environ['placement.context']
uuid = util.wsgi_path_item(req.environ, 'uuid')
- resource_provider = objects.ResourceProvider.get_by_uuid(
- context, uuid)
+ try:
+ resource_provider = objects.ResourceProvider.get_by_uuid(
+ context, uuid)
+ except exception.NotFound as exc:
+ raise webob.exc.HTTPNotFound(
+ _("No resource provider with uuid %(uuid)s found : %(error)s") %
+ {'uuid': uuid, 'error': exc},
+ json_formatter=util.json_error_formatter)
+
inventories = objects.InventoryList.get_all_by_resource_provider_uuid(
context, resource_provider.uuid)
import webob
from nova.api.openstack.placement import util
+from nova import exception
+from nova.i18n import _
from nova import objects
# get_all_by_resource_provider_uuid can return an empty list.
# It is also needed for the generation, used in the outgoing
# representation.
- resource_provider = objects.ResourceProvider.get_by_uuid(
- context, uuid)
+ try:
+ resource_provider = objects.ResourceProvider.get_by_uuid(
+ context, uuid)
+ except exception.NotFound as exc:
+ raise webob.exc.HTTPNotFound(
+ _("No resource provider with uuid %(uuid)s found: %(error)s") %
+ {'uuid': uuid, 'error': exc},
+ json_formatter=util.json_error_formatter)
+
usage = objects.UsageList.get_all_by_resource_provider_uuid(
context, uuid)
- name: inventories for missing provider
GET: /resource_providers/7260669a-e3d4-4867-aaa7-683e2ab6958c/inventories
status: 404
+ response_strings:
+ - No resource provider with uuid 7260669a-e3d4-4867-aaa7-683e2ab6958c found
- name: post new resource provider
POST: /resource_providers
- name: delete inventory again
DELETE: /resource_providers/$ENVIRON['RP_UUID']/inventories/IPV4_ADDRESS
status: 404
+ response_strings:
+ - No inventory of class IPV4_ADDRESS found for delete
- name: get missing inventory class
GET: /resource_providers/$ENVIRON['RP_UUID']/inventories/IPV4_ADDRESS
status: 404
+ response_strings:
+ - No inventory of class IPV4_ADDRESS for $ENVIRON['RP_UUID']
- name: get invalid inventory class
GET: /resource_providers/$ENVIRON['RP_UUID']/inventories/HOUSE
status: 404
+ response_strings:
+ - No inventory of class HOUSE for $ENVIRON['RP_UUID']
- name: create another resource provider
POST: /resource_providers
- name: fail to get usages for missing provider
GET: /resource_providers/fae14fa3-4b43-498c-a33c-4a1d00edb577/usages
status: 404
+ response_strings:
+ - No resource provider with uuid fae14fa3-4b43-498c-a33c-4a1d00edb577 found
- name: create provider
POST: /resource_providers