Add '--force' option to 'backup delete' command in volumev2
Add '--force' option to 'backup delete' command in volumev2 (v2 only) to allow delete in state other than error or available. Change-Id: I661ea0d465db227e374cbacdde0206fa1a6dd3d5 Closes-Bug: #1597188
This commit is contained in:
parent
44d4188149
commit
f5aef9ac36
@ -2,7 +2,7 @@
|
||||
backup
|
||||
======
|
||||
|
||||
Block Storage v1
|
||||
Block Storage v1, v2
|
||||
|
||||
backup create
|
||||
-------------
|
||||
@ -53,8 +53,15 @@ Delete backup(s)
|
||||
.. code:: bash
|
||||
|
||||
os backup delete
|
||||
[--force]
|
||||
<backup> [<backup> ...]
|
||||
|
||||
.. option:: --force
|
||||
|
||||
Allow delete in state other than error or available
|
||||
|
||||
*Volume version 2 only*
|
||||
|
||||
.. _backup_delete-backup:
|
||||
.. describe:: <backup>
|
||||
|
||||
|
@ -156,7 +156,23 @@ class TestBackupDelete(TestBackup):
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.backups_mock.delete.assert_called_with(self.backup.id)
|
||||
self.backups_mock.delete.assert_called_with(self.backup.id, False)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_backup_delete_with_force(self):
|
||||
arglist = [
|
||||
'--force',
|
||||
self.backup.id,
|
||||
]
|
||||
verifylist = [
|
||||
('force', True),
|
||||
("backups", [self.backup.id])
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.backups_mock.delete.assert_called_with(self.backup.id, True)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
|
@ -92,6 +92,12 @@ class DeleteBackup(command.Command):
|
||||
nargs="+",
|
||||
help=_("Backup(s) to delete (name or ID)")
|
||||
)
|
||||
parser.add_argument(
|
||||
'--force',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=_("Allow delete in state other than error or available")
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -99,7 +105,7 @@ class DeleteBackup(command.Command):
|
||||
for backup in parsed_args.backups:
|
||||
backup_id = utils.find_resource(
|
||||
volume_client.backups, backup).id
|
||||
volume_client.backups.delete(backup_id)
|
||||
volume_client.backups.delete(backup_id, parsed_args.force)
|
||||
|
||||
|
||||
class ListBackup(command.Lister):
|
||||
|
6
releasenotes/notes/bug-1597188-a2ff62b809865365.yaml
Normal file
6
releasenotes/notes/bug-1597188-a2ff62b809865365.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``--force`` option to ``backup delete`` command to allow delete
|
||||
in state other than error or available.
|
||||
[Bug `1597188 <https://bugs.launchpad.net/bugs/1597188>`_]
|
Loading…
Reference in New Issue
Block a user