Merge "Accept deleting multiple snapshots in one shot"
This commit is contained in:
@@ -285,6 +285,9 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
def delete_snapshots_1234(self, **kw):
|
def delete_snapshots_1234(self, **kw):
|
||||||
return (202, {}, {})
|
return (202, {}, {})
|
||||||
|
|
||||||
|
def delete_snapshots_5678(self, **kw):
|
||||||
|
return (202, {}, {})
|
||||||
|
|
||||||
#
|
#
|
||||||
# Volumes
|
# Volumes
|
||||||
#
|
#
|
||||||
|
@@ -366,3 +366,7 @@ class ShellTest(utils.TestCase):
|
|||||||
def test_quota_delete(self):
|
def test_quota_delete(self):
|
||||||
self.run_command('quota-delete 1234')
|
self.run_command('quota-delete 1234')
|
||||||
self.assert_called('DELETE', '/os-quota-sets/1234')
|
self.assert_called('DELETE', '/os-quota-sets/1234')
|
||||||
|
|
||||||
|
def test_snapshot_delete_multiple(self):
|
||||||
|
self.run_command('snapshot-delete 1234 5678')
|
||||||
|
self.assert_called('DELETE', '/snapshots/5678')
|
||||||
|
@@ -294,6 +294,9 @@ class FakeHTTPClient(base_client.HTTPClient):
|
|||||||
def delete_snapshots_1234(self, **kw):
|
def delete_snapshots_1234(self, **kw):
|
||||||
return (202, {}, {})
|
return (202, {}, {})
|
||||||
|
|
||||||
|
def delete_snapshots_5678(self, **kw):
|
||||||
|
return (202, {}, {})
|
||||||
|
|
||||||
#
|
#
|
||||||
# Volumes
|
# Volumes
|
||||||
#
|
#
|
||||||
|
@@ -366,3 +366,7 @@ class ShellTest(utils.TestCase):
|
|||||||
def test_quota_delete(self):
|
def test_quota_delete(self):
|
||||||
self.run_command('quota-delete 1234')
|
self.run_command('quota-delete 1234')
|
||||||
self.assert_called('DELETE', '/os-quota-sets/1234')
|
self.assert_called('DELETE', '/os-quota-sets/1234')
|
||||||
|
|
||||||
|
def test_snapshot_delete_multiple(self):
|
||||||
|
self.run_command('snapshot-delete 5678')
|
||||||
|
self.assert_called('DELETE', '/snapshots/5678')
|
||||||
|
@@ -481,13 +481,21 @@ def do_snapshot_create(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot',
|
@utils.arg('snapshot',
|
||||||
metavar='<snapshot>',
|
metavar='<snapshot>', nargs='+',
|
||||||
help='Name or ID of the snapshot to delete.')
|
help='Name or ID of the snapshot(s) to delete.')
|
||||||
@utils.service_type('volume')
|
@utils.service_type('volume')
|
||||||
def do_snapshot_delete(cs, args):
|
def do_snapshot_delete(cs, args):
|
||||||
"""Remove a snapshot."""
|
"""Remove one or more snapshots."""
|
||||||
snapshot = _find_volume_snapshot(cs, args.snapshot)
|
failure_count = 0
|
||||||
snapshot.delete()
|
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>',
|
@utils.arg('snapshot', metavar='<snapshot>',
|
||||||
|
@@ -531,13 +531,21 @@ def do_snapshot_create(cs, args):
|
|||||||
|
|
||||||
|
|
||||||
@utils.arg('snapshot',
|
@utils.arg('snapshot',
|
||||||
metavar='<snapshot>',
|
metavar='<snapshot>', nargs='+',
|
||||||
help='Name or ID of the snapshot to delete.')
|
help='Name or ID of the snapshot(s) to delete.')
|
||||||
@utils.service_type('volumev2')
|
@utils.service_type('volumev2')
|
||||||
def do_snapshot_delete(cs, args):
|
def do_snapshot_delete(cs, args):
|
||||||
"""Remove a snapshot."""
|
"""Remove one or more snapshots."""
|
||||||
snapshot = _find_volume_snapshot(cs, args.snapshot)
|
failure_count = 0
|
||||||
snapshot.delete()
|
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>',
|
@utils.arg('snapshot', metavar='<snapshot>',
|
||||||
|
@@ -34,6 +34,7 @@ MASTER
|
|||||||
------
|
------
|
||||||
.. _1255905: http://bugs.launchpad.net/python-cinderclient/+bug/1255905
|
.. _1255905: http://bugs.launchpad.net/python-cinderclient/+bug/1255905
|
||||||
.. _1267168: http://bugs.launchpad.net/python-cinderclient/+bug/1267168
|
.. _1267168: http://bugs.launchpad.net/python-cinderclient/+bug/1267168
|
||||||
|
.. _1284540: http://bugs.launchpad.net/python-cinderclient/+bug/1284540
|
||||||
|
|
||||||
1.0.8
|
1.0.8
|
||||||
-----
|
-----
|
||||||
|
Reference in New Issue
Block a user