Merge "Allow "cinder backup-delete" to delete multiple backups in one request"
This commit is contained in:
@@ -811,6 +811,12 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
def delete_backups_76a17945_3c6f_435c_975b_b5685db10b62(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def delete_backups_1234(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def delete_backups_5678(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def post_backups(self, **kw):
|
||||
base_uri = 'http://localhost:8776'
|
||||
tenant_id = '0fa851f6668144cf9cd8c8419c1646c1'
|
||||
|
@@ -415,6 +415,11 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('backup-create 1234 --snapshot-id 4321')
|
||||
self.assert_called('POST', '/backups')
|
||||
|
||||
def test_multiple_backup_delete(self):
|
||||
self.run_command('backup-delete 1234 5678')
|
||||
self.assert_called_anytime('DELETE', '/backups/1234')
|
||||
self.assert_called('DELETE', '/backups/5678')
|
||||
|
||||
def test_restore(self):
|
||||
self.run_command('backup-restore 1234')
|
||||
self.assert_called('POST', '/backups/1234/restore')
|
||||
|
@@ -1472,13 +1472,22 @@ def do_backup_list(cs, args):
|
||||
utils.print_list(backups, columns)
|
||||
|
||||
|
||||
@utils.arg('backup', metavar='<backup>',
|
||||
help='Name or ID of backup to delete.')
|
||||
@utils.arg('backup', metavar='<backup>', nargs='+',
|
||||
help='Name or ID of backup(s) to delete.')
|
||||
@utils.service_type('volumev2')
|
||||
def do_backup_delete(cs, args):
|
||||
"""Removes a backup."""
|
||||
backup = _find_backup(cs, args.backup)
|
||||
backup.delete()
|
||||
"""Removes one or more backups."""
|
||||
failure_count = 0
|
||||
for backup in args.backup:
|
||||
try:
|
||||
_find_backup(cs, backup).delete()
|
||||
print("Request to delete backup %s has been accepted." % (backup))
|
||||
except Exception as e:
|
||||
failure_count += 1
|
||||
print("Delete for backup %s failed: %s" % (backup, e))
|
||||
if failure_count == len(args.backup):
|
||||
raise exceptions.CommandError("Unable to delete any of the specified "
|
||||
"backups.")
|
||||
|
||||
|
||||
@utils.arg('backup', metavar='<backup>',
|
||||
|
Reference in New Issue
Block a user