Merge "Handle CannotDeleteParentResourceProvider to 409 Conflict" into stable/queens

This commit is contained in:
Zuul 2018-07-08 02:05:29 +00:00 committed by Gerrit Code Review
commit c70bce56e7
3 changed files with 14 additions and 0 deletions

View File

@ -130,6 +130,10 @@ def delete_resource_provider(req):
except exception.NotFound as exc:
raise webob.exc.HTTPNotFound(
_("No resource provider with uuid %s found for delete") % uuid)
except exception.CannotDeleteParentResourceProvider as exc:
raise webob.exc.HTTPConflict(
_("Unable to delete parent resource provider %(rp_uuid)s: "
"It has child resource providers.") % {'rp_uuid': uuid})
req.response.status = 204
req.response.content_type = None
return req.response

View File

@ -360,6 +360,13 @@ tests:
response_strings:
- 'un-parenting a provider is not currently allowed'
- name: 409 conflict while trying to delete parent with existing child
DELETE: /resource_providers/$ENVIRON['PARENT_PROVIDER_UUID']
status: 409
response_strings:
- "Unable to delete parent resource provider
$ENVIRON['PARENT_PROVIDER_UUID']: It has child resource providers."
- name: list all resource providers in a tree that does not exist
GET: /resource_providers?in_tree=$ENVIRON['ALT_PARENT_PROVIDER_UUID']
response_json_paths:

View File

@ -106,6 +106,9 @@ A `409 Conflict` response code will be returned if there exist
allocations records for any of the inventories that would be deleted
as a result of removing the resource provider.
This error code will be also returned if there are existing child resource
providers under the parent resource provider being deleted.
Request
-------