Client support for --force option

Change-Id: I90d3dd52cbe68de336a69e0f73d1d6b0bfeaadfd
Partial-Bug: #1619775
This commit is contained in:
Bharath Thiruveedula 2016-09-09 12:38:10 +05:30
parent 592debaafd
commit 8aba477826
3 changed files with 10 additions and 4 deletions

View File

@ -132,7 +132,9 @@ class Manager(object):
if body: if body:
return self.resource_class(self, 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) self.api.raw_request('DELETE', url)

View File

@ -100,8 +100,9 @@ class ContainerManager(base.Manager):
"Key must be in %s" % ','.join(CREATION_ATTRIBUTES)) "Key must be in %s" % ','.join(CREATION_ATTRIBUTES))
return self._create(self._path(), new) return self._create(self._path(), new)
def delete(self, id): def delete(self, id, force):
return self._delete(self._path(id)) return self._delete(self._path(id),
qparams={'force': force})
def _action(self, id, action, method='POST', qparams=None, **kwargs): def _action(self, id, action, method='POST', qparams=None, **kwargs):
if qparams: if qparams:

View File

@ -84,11 +84,14 @@ def do_list(cs, args):
metavar='<container>', metavar='<container>',
nargs='+', nargs='+',
help='ID or name of the (container)s to delete.') 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): def do_delete(cs, args):
"""Delete specified containers.""" """Delete specified containers."""
for container in args.containers: for container in args.containers:
try: try:
cs.containers.delete(container) cs.containers.delete(container, args.force)
print("Request to delete container %s has been accepted." % print("Request to delete container %s has been accepted." %
container) container)
except Exception as e: except Exception as e: