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: