summaryrefslogtreecommitdiff
path: root/openstackclient/volume/v1
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2023-05-17 12:27:45 +0100
committerStephen Finucane <stephenfin@redhat.com>2023-05-17 16:50:16 +0100
commit629eb33c4dcb73d44d1a4c6105e40d28f6cebdfc (patch)
tree485a8b83d670a19d644eab733528c2e29dc1a1aa /openstackclient/volume/v1
parent31ae635ffe0a2c37ab2bda394d2b072d7e5acff9 (diff)
downloadpython-openstackclient-629eb33c4dcb73d44d1a4c6105e40d28f6cebdfc.tar.gz
volume: Add 'volume qos set --no-property' option
Supporting "--no-property" option will apply user a convenient way to clean all properties of volume qos in a short command. The patch adds "--no-property" option in "volume qos set" command and update related test cases and docs. Change-Id: I1fb5b4f0a923bbf557a3af3f63809bde9e84ffd4
Diffstat (limited to 'openstackclient/volume/v1')
-rw-r--r--openstackclient/volume/v1/qos_specs.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/openstackclient/volume/v1/qos_specs.py b/openstackclient/volume/v1/qos_specs.py
index 87e32ff4..830d5d82 100644
--- a/openstackclient/volume/v1/qos_specs.py
+++ b/openstackclient/volume/v1/qos_specs.py
@@ -256,6 +256,16 @@ class SetQos(command.Command):
help=_('QoS specification to modify (name or ID)'),
)
parser.add_argument(
+ '--no-property',
+ dest='no_property',
+ action='store_true',
+ help=_(
+ 'Remove all properties from <qos-spec> '
+ '(specify both --no-property and --property to remove the '
+ 'current properties before setting new properties)'
+ ),
+ )
+ parser.add_argument(
'--property',
metavar='<key=value>',
action=parseractions.KeyValueAction,
@@ -272,8 +282,29 @@ class SetQos(command.Command):
volume_client.qos_specs, parsed_args.qos_spec
)
+ result = 0
+ if parsed_args.no_property:
+ try:
+ key_list = list(qos_spec._info['specs'].keys())
+ volume_client.qos_specs.unset_keys(qos_spec.id, key_list)
+ except Exception as e:
+ LOG.error(_("Failed to clean qos properties: %s"), e)
+ result += 1
+
if parsed_args.property:
- volume_client.qos_specs.set_keys(qos_spec.id, parsed_args.property)
+ try:
+ volume_client.qos_specs.set_keys(
+ qos_spec.id,
+ parsed_args.property,
+ )
+ except Exception as e:
+ LOG.error(_("Failed to set qos property: %s"), e)
+ result += 1
+
+ if result > 0:
+ raise exceptions.CommandError(
+ _("One or more of the set operations failed")
+ )
class ShowQos(command.ShowOne):