summaryrefslogtreecommitdiff
path: root/openstackclient/volume/v2/qos_specs.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-05-17 23:20:28 +0000
committerGerrit Code Review <review@openstack.org>2023-05-17 23:20:28 +0000
commit4a62c7399210dd2f23aba4df000c17f1dab03817 (patch)
tree4e065411c863334bc53ab31cf2284f9e9c494c39 /openstackclient/volume/v2/qos_specs.py
parentd0a17d48a9972a572f22cc6f73525ec8a87c44ef (diff)
parent629eb33c4dcb73d44d1a4c6105e40d28f6cebdfc (diff)
downloadpython-openstackclient-4a62c7399210dd2f23aba4df000c17f1dab03817.tar.gz
Merge "volume: Add 'volume qos set --no-property' option"HEADmaster
Diffstat (limited to 'openstackclient/volume/v2/qos_specs.py')
-rw-r--r--openstackclient/volume/v2/qos_specs.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/openstackclient/volume/v2/qos_specs.py b/openstackclient/volume/v2/qos_specs.py
index 2c06ee34..0454ecae 100644
--- a/openstackclient/volume/v2/qos_specs.py
+++ b/openstackclient/volume/v2/qos_specs.py
@@ -258,6 +258,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,
@@ -274,8 +284,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):