Skip to content

Commit 4e46c04

Browse files
author
Huanxuan Ao
committed
Add "--force" option to "volume qos delete" command
Add ``--force`` option to ``volume qos delete`` command in volume v1 and v2 to allow users to delete in-use QoS specification(s). Change-Id: I46036e5f55ced8b8a1be54c521f2a5c242b89160 Closes-Bug: #1596821
1 parent 9e47688 commit 4e46c04

6 files changed

Lines changed: 60 additions & 5 deletions

File tree

doc/source/command-objects/volume-qos.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ Delete QoS specification
5858
.. code:: bash
5959
6060
os volume qos delete
61+
[--force]
6162
<qos-spec> [<qos-spec> ...]
6263
64+
.. option:: --force
65+
66+
Allow to delete in-use QoS specification(s)
67+
6368
.. describe:: <qos-spec>
6469

6570
QoS specification(s) to delete (name or ID)

openstackclient/tests/volume/v1/test_qos_specs.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def test_qos_delete_with_id(self):
211211

212212
result = self.cmd.take_action(parsed_args)
213213

214-
self.qos_mock.delete.assert_called_with(volume_fakes.qos_id)
214+
self.qos_mock.delete.assert_called_with(volume_fakes.qos_id, False)
215215
self.assertIsNone(result)
216216

217217
def test_qos_delete_with_name(self):
@@ -225,7 +225,23 @@ def test_qos_delete_with_name(self):
225225

226226
result = self.cmd.take_action(parsed_args)
227227

228-
self.qos_mock.delete.assert_called_with(volume_fakes.qos_id)
228+
self.qos_mock.delete.assert_called_with(volume_fakes.qos_id, False)
229+
self.assertIsNone(result)
230+
231+
def test_qos_delete_with_force(self):
232+
arglist = [
233+
'--force',
234+
volume_fakes.qos_id
235+
]
236+
verifylist = [
237+
('force', True),
238+
('qos_specs', [volume_fakes.qos_id])
239+
]
240+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
241+
242+
result = self.cmd.take_action(parsed_args)
243+
244+
self.qos_mock.delete.assert_called_with(volume_fakes.qos_id, True)
229245
self.assertIsNone(result)
230246

231247

openstackclient/tests/volume/v2/test_qos_specs.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,23 @@ def test_qos_delete(self):
175175

176176
result = self.cmd.take_action(parsed_args)
177177

178-
self.qos_mock.delete.assert_called_with(self.qos_spec.id)
178+
self.qos_mock.delete.assert_called_with(self.qos_spec.id, False)
179+
self.assertIsNone(result)
180+
181+
def test_qos_delete_with_force(self):
182+
arglist = [
183+
'--force',
184+
self.qos_spec.id
185+
]
186+
verifylist = [
187+
('force', True),
188+
('qos_specs', [self.qos_spec.id])
189+
]
190+
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
191+
192+
result = self.cmd.take_action(parsed_args)
193+
194+
self.qos_mock.delete.assert_called_with(self.qos_spec.id, True)
179195
self.assertIsNone(result)
180196

181197

openstackclient/volume/v1/qos_specs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ def get_parser(self, prog_name):
103103
nargs="+",
104104
help=_('QoS specification(s) to delete (name or ID)'),
105105
)
106+
parser.add_argument(
107+
'--force',
108+
action='store_true',
109+
default=False,
110+
help=_("Allow to delete in-use QoS specification(s)")
111+
)
106112
return parser
107113

108114
def take_action(self, parsed_args):
109115
volume_client = self.app.client_manager.volume
110116
for qos in parsed_args.qos_specs:
111117
qos_spec = utils.find_resource(volume_client.qos_specs, qos)
112-
volume_client.qos_specs.delete(qos_spec.id)
118+
volume_client.qos_specs.delete(qos_spec.id, parsed_args.force)
113119

114120

115121
class DisassociateQos(command.Command):

openstackclient/volume/v2/qos_specs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ def get_parser(self, prog_name):
103103
nargs="+",
104104
help=_('QoS specification(s) to delete (name or ID)'),
105105
)
106+
parser.add_argument(
107+
'--force',
108+
action='store_true',
109+
default=False,
110+
help=_("Allow to delete in-use QoS specification(s)")
111+
)
106112
return parser
107113

108114
def take_action(self, parsed_args):
109115
volume_client = self.app.client_manager.volume
110116
for qos in parsed_args.qos_specs:
111117
qos_spec = utils.find_resource(volume_client.qos_specs, qos)
112-
volume_client.qos_specs.delete(qos_spec.id)
118+
volume_client.qos_specs.delete(qos_spec.id, parsed_args.force)
113119

114120

115121
class DisassociateQos(command.Command):
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 ``volume qos delete`` command to allow users to
5+
delete in-use QoS specification(s).
6+
[Bug `1596821 <https://bugs.launchpad.net/bugs/1596821>`_]

0 commit comments

Comments
 (0)