From 8aba477826c949795eede58295fd3e0e74b053b5 Mon Sep 17 00:00:00 2001 From: Bharath Thiruveedula Date: Fri, 9 Sep 2016 12:38:10 +0530 Subject: [PATCH] Client support for --force option Change-Id: I90d3dd52cbe68de336a69e0f73d1d6b0bfeaadfd Partial-Bug: #1619775 --- zunclient/common/base.py | 4 +++- zunclient/v1/containers.py | 5 +++-- zunclient/v1/containers_shell.py | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/zunclient/common/base.py b/zunclient/common/base.py index a17adb55..cc53685e 100644 --- a/zunclient/common/base.py +++ b/zunclient/common/base.py @@ -132,7 +132,9 @@ class Manager(object): if body: return self.resource_class(self, body) - def _delete(self, url): + def _delete(self, url, qparams=None): + if qparams: + url = "%s?%s" % (url, urlparse.urlencode(qparams)) self.api.raw_request('DELETE', url) diff --git a/zunclient/v1/containers.py b/zunclient/v1/containers.py index a87baa71..0d32e367 100644 --- a/zunclient/v1/containers.py +++ b/zunclient/v1/containers.py @@ -100,8 +100,9 @@ class ContainerManager(base.Manager): "Key must be in %s" % ','.join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) - def delete(self, id): - return self._delete(self._path(id)) + def delete(self, id, force): + return self._delete(self._path(id), + qparams={'force': force}) def _action(self, id, action, method='POST', qparams=None, **kwargs): if qparams: diff --git a/zunclient/v1/containers_shell.py b/zunclient/v1/containers_shell.py index fc84a4fc..391cb330 100644 --- a/zunclient/v1/containers_shell.py +++ b/zunclient/v1/containers_shell.py @@ -84,11 +84,14 @@ def do_list(cs, args): metavar='', nargs='+', help='ID or name of the (container)s to delete.') +@utils.arg('--force', + action='store_true', + help='Force delete the container.') def do_delete(cs, args): """Delete specified containers.""" for container in args.containers: try: - cs.containers.delete(container) + cs.containers.delete(container, args.force) print("Request to delete container %s has been accepted." % container) except Exception as e: