diff --git a/nova/api/openstack/placement/handlers/inventory.py b/nova/api/openstack/placement/handlers/inventory.py index b9f26ebbf..3fed8ac42 100644 --- a/nova/api/openstack/placement/handlers/inventory.py +++ b/nova/api/openstack/placement/handlers/inventory.py @@ -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 diff --git a/nova/tests/functional/api/openstack/placement/gabbits/with-allocations.yaml b/nova/tests/functional/api/openstack/placement/gabbits/with-allocations.yaml index c1c903a22..03274cadd 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/with-allocations.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/with-allocations.yaml @@ -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: