summaryrefslogtreecommitdiff
path: root/cinderclient/v1
diff options
context:
space:
mode:
authorXavier Queralt <xqueralt@redhat.com>2014-02-25 10:25:24 +0100
committerXavier Queralt <xqueralt@redhat.com>2014-04-03 10:21:23 +0200
commit5a080b4d474a9e8ada54f4fa8c7b4a088d13f965 (patch)
tree3320a2115a6ca6cc5cb69b9bf84f55956d33a45e /cinderclient/v1
parent5278bdb0c53e34a6c647a0f8f6158f37236a9d2f (diff)
downloadpython-cinderclient-5a080b4d474a9e8ada54f4fa8c7b4a088d13f965.tar.gz
Accept deleting multiple snapshots in one shot
In bug 1241941 the delete and force-delete commands were updated to accept multiple volumes for deleting in the same call. This patch adds the same behaviour to the snapshot-delete command. Closes-Bug: #1284540 Change-Id: I5e4bf8641d7fd261fa24b03832bad08007e43c12
Diffstat (limited to 'cinderclient/v1')
-rw-r--r--cinderclient/v1/shell.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py
index 6a11c2a..6615500 100644
--- a/cinderclient/v1/shell.py
+++ b/cinderclient/v1/shell.py
@@ -481,13 +481,21 @@ def do_snapshot_create(cs, args):
@utils.arg('snapshot',
- metavar='<snapshot>',
- help='Name or ID of the snapshot to delete.')
+ metavar='<snapshot>', nargs='+',
+ help='Name or ID of the snapshot(s) to delete.')
@utils.service_type('volume')
def do_snapshot_delete(cs, args):
- """Remove a snapshot."""
- snapshot = _find_volume_snapshot(cs, args.snapshot)
- snapshot.delete()
+ """Remove one or more snapshots."""
+ failure_count = 0
+ for snapshot in args.snapshot:
+ try:
+ _find_volume_snapshot(cs, snapshot).delete()
+ except Exception as e:
+ failure_count += 1
+ print("Delete for snapshot %s failed: %s" % (snapshot, e))
+ if failure_count == len(args.snapshot):
+ raise exceptions.CommandError("Unable to delete any of the specified "
+ "snapshots.")
@utils.arg('snapshot', metavar='<snapshot>',