Raise 409 exception while deleting running container

Change-Id: I597cbd473e204dd244e95e4814bf650437b540c9
Closes-Bug: #1614384
This commit is contained in:
Bharath Thiruveedula 2016-08-24 00:11:27 +05:30
parent 04613018b3
commit 3133041604
2 changed files with 9 additions and 0 deletions

View File

@ -339,3 +339,9 @@ class ContainerNotFound(HTTPNotFound):
class ContainerAlreadyExists(ResourceExists):
message = _("A container with UUID %(uuid)s already exists.")
class ContainerRunningException(ZunException):
message = _("The container %(id)s is running."
"Please stop and delete the container.")
code = 409

View File

@ -72,6 +72,9 @@ class Manager(object):
return container
except Exception as e:
LOG.exception(_LE("Unexpected exception: %s"), str(e))
if e.response.status_code == 409:
raise exception.ContainerRunningException(
id=container.container_id)
raise e
@translate_exception