Add INVENTORY_INUSE to DELETE /rp/{u}/inventories

Change I9a833aa35d474caa35e640bbad6c436a3b16ac5e added a custom error
code framework to the placement API and, as an example of a specific
error code, created INVENTORY_INUSE ('placement.inventory.inuse') for
PUT /resource_providers/{uuid}/inventories.  We have essentially the
same error condition for DELETE /resource_providers/{uuid}/inventories,
so this change set adds the same error code there.

Change-Id: I52715205e607cef5deee1351099725885b282c08
This commit is contained in:
Eric Fried
2018-05-15 07:52:45 -05:00
parent 468176191b
commit 5ca2743438
2 changed files with 15 additions and 1 deletions

View File

@ -362,7 +362,8 @@ def delete_inventories(req):
except exception.InventoryInUse as ex:
# NOTE(mriedem): This message cannot change without impacting the
# nova.scheduler.client.report._RE_INV_IN_USE regex.
raise webob.exc.HTTPConflict(ex.format_message())
raise webob.exc.HTTPConflict(ex.format_message(),
comment=errors.INVENTORY_INUSE)
response = req.response
response.status = 204

View File

@ -55,6 +55,19 @@ tests:
response_strings:
- "Inventory for 'VCPU, DISK_GB' on resource provider '$ENVIRON['RP_UUID']' in use"
- name: fail to delete all inventory 1.23
DELETE: /resource_providers/$ENVIRON['RP_UUID']/inventories
request_headers:
accept: application/json
openstack-api-version: placement 1.23
status: 409
response_headers:
content-type: /application/json/
response_strings:
- "Inventory for 'VCPU, DISK_GB' on resource provider '$ENVIRON['RP_UUID']' in use"
response_json_paths:
$.errors[0].code: placement.inventory.inuse
- name: get total usages by project
GET: /usages?project_id=$ENVIRON['PROJECT_ID']
request_headers: