From 043d40df5eaea764971b67d5692267c7ad94556a Mon Sep 17 00:00:00 2001 From: Feng Shengqin Date: Tue, 15 Jan 2019 19:13:36 +0800 Subject: [PATCH] Wait for the container to delete Change-Id: I30a21f66c332c91a3af59a63805ec1d34f2bd3a8 --- zunclient/osc/v1/containers.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zunclient/osc/v1/containers.py b/zunclient/osc/v1/containers.py index 10aff442..a89ac5f5 100644 --- a/zunclient/osc/v1/containers.py +++ b/zunclient/osc/v1/containers.py @@ -405,6 +405,10 @@ class DeleteContainer(command.Command): action="store_true", default=False, help='Delete container(s) in all projects by name.') + parser.add_argument( + '--wait', + action='store_true', + help='Wait for create to complete') return parser def take_action(self, parsed_args): @@ -421,6 +425,18 @@ class DeleteContainer(command.Command): client.containers.delete(**opts) print(_('Request to delete container %s has been accepted.') % 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: print("Delete for container %(container)s failed: %(e)s" % {'container': container, 'e': e})