Wait for the container to delete
Change-Id: I30a21f66c332c91a3af59a63805ec1d34f2bd3a8
This commit is contained in:

committed by
feng.shengqin

parent
b17ff61f2c
commit
043d40df5e
@@ -405,6 +405,10 @@ class DeleteContainer(command.Command):
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
help='Delete container(s) in all projects by name.')
|
help='Delete container(s) in all projects by name.')
|
||||||
|
parser.add_argument(
|
||||||
|
'--wait',
|
||||||
|
action='store_true',
|
||||||
|
help='Wait for create to complete')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -421,6 +425,18 @@ class DeleteContainer(command.Command):
|
|||||||
client.containers.delete(**opts)
|
client.containers.delete(**opts)
|
||||||
print(_('Request to delete container %s has been accepted.')
|
print(_('Request to delete container %s has been accepted.')
|
||||||
% container)
|
% container)
|
||||||
|
if parsed_args.wait:
|
||||||
|
if utils.wait_for_delete(
|
||||||
|
client.containers,
|
||||||
|
container,
|
||||||
|
timeout=30
|
||||||
|
):
|
||||||
|
print("Delete for container %(container)s success." %
|
||||||
|
{'container': container})
|
||||||
|
else:
|
||||||
|
print("Delete for container %(container)s failed." %
|
||||||
|
{'container': container})
|
||||||
|
raise SystemExit
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Delete for container %(container)s failed: %(e)s" %
|
print("Delete for container %(container)s failed: %(e)s" %
|
||||||
{'container': container, 'e': e})
|
{'container': container, 'e': e})
|
||||||
|
Reference in New Issue
Block a user