diff options
Diffstat (limited to 'openstackclient/volume/v2/qos_specs.py')
-rw-r--r-- | openstackclient/volume/v2/qos_specs.py | 33 |
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): |