From 683bca82151bf1b33b172d439e0fd1ed47dabe57 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Wed, 2 Feb 2022 17:08:47 +0000 Subject: [PATCH] Add filter flags for QoS rule types Added two filter flags for the QoS rule type API definition: - all_supported: if True, the listing call will print all QoS rule types supported by at least one loaded mechanism driver. - all_rules: if True, the listing call will print all QoS rule types supported by the Neutron server. Both flags are exclusive and not required. Change-Id: I8836de91fb5f47f64b44035bfe3fbb4f8a9f63a0 Related-Bug: #1959749 --- api-ref/source/v2/parameters.yaml | 14 +++++ api-ref/source/v2/qos.inc | 8 +++ neutron_lib/api/definitions/__init__.py | 2 + neutron_lib/api/definitions/base.py | 1 + .../api/definitions/qos_rule_type_filter.py | 55 +++++++++++++++++++ .../definitions/test_qos_rule_type_filter.py | 25 +++++++++ ...qos-rule-type-filter-dbac0ec80ce342f3.yaml | 8 +++ 7 files changed, 113 insertions(+) create mode 100644 neutron_lib/api/definitions/qos_rule_type_filter.py create mode 100644 neutron_lib/tests/unit/api/definitions/test_qos_rule_type_filter.py create mode 100644 releasenotes/notes/qos-rule-type-filter-dbac0ec80ce342f3.yaml diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index 59bfe83d2..fd85b0126 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -5532,6 +5532,20 @@ qos-rule-type: in: body required: true type: string +qos-rule-type-all-rules: + description: | + Set to ``true`` to return all QoS rule types implemented in the Neutron + server. + in: body + required: false + type: boolean +qos-rule-type-all-supported: + description: | + Set to ``true`` to return all QoS rule types supported by any loaded + driver. + in: body + required: false + type: boolean qos-rule-types: description: | A list of QoS ``rule_type`` objects. diff --git a/api-ref/source/v2/qos.inc b/api-ref/source/v2/qos.inc index 1185817c4..6b1a896c7 100644 --- a/api-ref/source/v2/qos.inc +++ b/api-ref/source/v2/qos.inc @@ -34,6 +34,14 @@ Normal response codes: 200 Error response codes: 401 +Request +------- + +.. rest_parameters:: parameters.yaml + + - all_supported: qos-rule-type-all-supported + - all_rules: qos-rule-type-all-rules + Response Parameters ------------------- diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 41cddcfc1..9863e79a9 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -107,6 +107,7 @@ from neutron_lib.api.definitions import qos_pps_minimum_rule from neutron_lib.api.definitions import qos_pps_minimum_rule_alias from neutron_lib.api.definitions import qos_pps_rule from neutron_lib.api.definitions import qos_rule_type_details +from neutron_lib.api.definitions import qos_rule_type_filter from neutron_lib.api.definitions import qos_rules_alias from neutron_lib.api.definitions import quota_check_limit from neutron_lib.api.definitions import rbac_address_groups @@ -249,6 +250,7 @@ _ALL_API_DEFINITIONS = { qos_pps_minimum_rule_alias, qos_pps_rule, qos_rule_type_details, + qos_rule_type_filter, qos_rules_alias, quota_check_limit, rbac_address_groups, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 6067575fc..a710a4d4f 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -147,6 +147,7 @@ KNOWN_EXTENSIONS = ( 'qos-port-network-policy', 'qos-pps-minimum', 'qos-pps-minimum-rule-alias', + 'qos-rule-type-filter', 'qos-rules-alias', 'quotas', 'quota-check-limit', diff --git a/neutron_lib/api/definitions/qos_rule_type_filter.py b/neutron_lib/api/definitions/qos_rule_type_filter.py new file mode 100644 index 000000000..199af197f --- /dev/null +++ b/neutron_lib/api/definitions/qos_rule_type_filter.py @@ -0,0 +1,55 @@ +# Copyright 2022 Red Hat, Inc. +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api import converters +from neutron_lib.api.definitions import qos as qos_apidef +from neutron_lib import constants + + +ALIAS = 'qos-rule-type-filter' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Allow to filter the list of QoS rule types' +API_PREFIX = '' +DESCRIPTION = ('Allows to filter the QoS rule type list adding two new flags. ' + '"all_rules" prints all implemented QoS rule types.' + '"all_supported" prints all supported QoS rule types by the ' + 'loaded mechanism drivers') +UPDATED_TIMESTAMP = '2022-02-02T10:00:00-00:00' +QOS_RULE_TYPE_ALL_SUPPORTED = 'all_supported' +QOS_RULE_TYPE_ALL_RULES = 'all_rules' +RESOURCE_ATTRIBUTE_MAP = { + qos_apidef.RULE_TYPES: { + QOS_RULE_TYPE_ALL_RULES: { + 'allow_post': True, 'allow_put': True, + 'convert_to': converters.convert_to_boolean_if_not_none, + 'default': constants.ATTR_NOT_SPECIFIED, + 'is_filter': True, + 'is_visible': False + }, + QOS_RULE_TYPE_ALL_SUPPORTED: { + 'allow_post': True, 'allow_put': True, + 'convert_to': converters.convert_to_boolean_if_not_none, + 'default': constants.ATTR_NOT_SPECIFIED, + 'is_filter': True, + 'is_visible': False + } + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [qos_apidef.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_qos_rule_type_filter.py b/neutron_lib/tests/unit/api/definitions/test_qos_rule_type_filter.py new file mode 100644 index 000000000..08ab650e8 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_qos_rule_type_filter.py @@ -0,0 +1,25 @@ +# Copyright 2022 Red Hat, Inc. +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_lib.api.definitions import qos_rule_type_filter +from neutron_lib.tests.unit.api.definitions import base +from neutron_lib.tests.unit.api.definitions import test_qos + + +class QoSRuleTypeFilterTestCase(base.DefinitionBaseTestCase): + extension_module = qos_rule_type_filter + extension_resources = test_qos.QoSDefinitionTestCase.extension_resources + extension_attributes = (qos_rule_type_filter.QOS_RULE_TYPE_ALL_SUPPORTED, + qos_rule_type_filter.QOS_RULE_TYPE_ALL_RULES) diff --git a/releasenotes/notes/qos-rule-type-filter-dbac0ec80ce342f3.yaml b/releasenotes/notes/qos-rule-type-filter-dbac0ec80ce342f3.yaml new file mode 100644 index 000000000..a5ce7535c --- /dev/null +++ b/releasenotes/notes/qos-rule-type-filter-dbac0ec80ce342f3.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Added API definition for ``qos-rule-type-filter`` extension that adds two + new parameters to QoS rule type API: "all_supported" that is a flag to + filter all supported QoS rule types by at least one loaded mechanism + driver; "all_rules" that is a flag to filter all implemented QoS rule + types in the Neutron server.