Skip to content

Commit f1a27a7

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add '--force' option to 'backup delete' command in volumev2"
2 parents 7f8999b + f5aef9a commit f1a27a7

4 files changed

Lines changed: 38 additions & 3 deletions

File tree

doc/source/command-objects/backup.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
backup
33
======
44

5-
Block Storage v1
5+
Block Storage v1, v2
66

77
backup create
88
-------------
@@ -53,8 +53,15 @@ Delete backup(s)
5353
.. code:: bash
5454
5555
os backup delete
56+
[--force]
5657
<backup> [<backup> ...]
5758
59+
.. option:: --force
60+
61+
Allow delete in state other than error or available
62+
63+
*Volume version 2 only*
64+
5865
.. _backup_delete-backup:
5966
.. describe:: <backup>
6067

openstackclient/tests/volume/v2/test_backup.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,23 @@ def test_backup_delete(self):
156156

157157
result = self.cmd.take_action(parsed_args)
158158

159-
self.backups_mock.delete.assert_called_with(self.backup.id)
159+
self.backups_mock.delete.assert_called_with(self.backup.id, False)
160+
self.assertIsNone(result)
161+
162+
def test_backup_delete_with_force(self):
163+
arglist = [
164+
'--force',
165+
self.backup.id,
166+
]
167+
verifylist = [
168+
('force', True),
169+
("backups", [self.backup.id])
170+
]
171+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
172+
173+
result = self.cmd.take_action(parsed_args)
174+
175+
self.backups_mock.delete.assert_called_with(self.backup.id, True)
160176
self.assertIsNone(result)
161177

162178

openstackclient/volume/v2/backup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,20 @@ def get_parser(self, prog_name):
9292
nargs="+",
9393
help=_("Backup(s) to delete (name or ID)")
9494
)
95+
parser.add_argument(
96+
'--force',
97+
action='store_true',
98+
default=False,
99+
help=_("Allow delete in state other than error or available")
100+
)
95101
return parser
96102

97103
def take_action(self, parsed_args):
98104
volume_client = self.app.client_manager.volume
99105
for backup in parsed_args.backups:
100106
backup_id = utils.find_resource(
101107
volume_client.backups, backup).id
102-
volume_client.backups.delete(backup_id)
108+
volume_client.backups.delete(backup_id, parsed_args.force)
103109

104110

105111
class ListBackup(command.Lister):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
Add ``--force`` option to ``backup delete`` command to allow delete
5+
in state other than error or available.
6+
[Bug `1597188 <https://bugs.launchpad.net/bugs/1597188>`_]

0 commit comments

Comments
 (0)