From ab284169b2f4a859affc995dbd4cd4eebf7b96e1 Mon Sep 17 00:00:00 2001 From: Miguel Lavalle Date: Tue, 27 Nov 2018 18:15:08 -0600 Subject: [PATCH] Fix QoS alias api definition Change [1] wrongly attempted to re-define bandwidth_limit_rules, dscp_marking_rules and minimum_bandwidth_rules as first level API resources, leading to conflicts in the QoS API. We now define alias_bandwidth_limit_rules, alias_dscp_marking_rules and alias_minimum_bandwidth_rules that will enable users to perform GET, PUT and DELETE operations on the corresponding QoS rules without having to specify the associated policy ID. [1] I5366dfee9b760ff5c884981582cdd17245b4d16f Change-Id: I978668ee073c26d6e05ea5e5a0a4e16a7e513fa1 Partial-Bug: #1777627 --- api-ref/source/v2/qos.inc | 18 +++++++------- .../api/definitions/qos_rules_alias.py | 24 ++++++++++++------- .../api/definitions/test_qos_rules_alias.py | 7 +++--- ...-rules-alias-ext-fix-3f3f7dd21837cfec.yaml | 11 +++++++++ 4 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 releasenotes/notes/qos-rules-alias-ext-fix-3f3f7dd21837cfec.yaml diff --git a/api-ref/source/v2/qos.inc b/api-ref/source/v2/qos.inc index f92abe9aa..bac67fc8f 100644 --- a/api-ref/source/v2/qos.inc +++ b/api-ref/source/v2/qos.inc @@ -991,7 +991,7 @@ available in this API extension are: Show bandwidth limit rule details alias ======================================= -.. rest_method:: GET /v2.0/qos/bandwidth_limit_rules/{rule_id} +.. rest_method:: GET /v2.0/qos/alias_bandwidth_limit_rules/{rule_id} Please refer to `Show bandwidth limit rule details <#show-bandwidth-limit-rule-details>`__ @@ -1000,7 +1000,7 @@ for more information on the request, response and return codes. Update bandwidth limit rule alias ================================= -.. rest_method:: PUT /v2.0/qos/bandwidth_limit_rules/{rule_id} +.. rest_method:: PUT /v2.0/qos/alias_bandwidth_limit_rules/{rule_id} Please refer to `Update bandwidth limit rule <#update-bandwidth-limit-rule>`__ @@ -1009,7 +1009,7 @@ for more information on the request, response and return codes. Delete bandwidth limit rule alias ================================= -.. rest_method:: DELETE /v2.0/qos/bandwidth_limit_rules/{rule_id} +.. rest_method:: DELETE /v2.0/qos/alias_bandwidth_limit_rules/{rule_id} Please refer to `Delete bandwidth limit rule <#delete-bandwidth-limit-rule>`__ @@ -1018,7 +1018,7 @@ for more information on the request, response and return codes. Show DSCP marking rule details alias ==================================== -.. rest_method:: GET /v2.0/qos/dscp_marking_rules/{dscp_rule_id} +.. rest_method:: GET /v2.0/qos/alias_dscp_marking_rules/{dscp_rule_id} Please refer to `Show DSCP marking rule details <#show-dscp-marking-rule-details>`__ @@ -1027,7 +1027,7 @@ for more information on the request, response and return codes. Update DSCP marking rule alias ============================== -.. rest_method:: PUT /v2.0/qos/dscp_marking_rules/{dscp_rule_id} +.. rest_method:: PUT /v2.0/qos/alias_dscp_marking_rules/{dscp_rule_id} Please refer to `Update DSCP marking rule <#update-dscp-marking-rule>`__ @@ -1036,7 +1036,7 @@ for more information on the request, response and return codes. Delete DSCP marking rule alias ============================== -.. rest_method:: DELETE /v2.0/qos/dscp_marking_rules/{dscp_rule_id} +.. rest_method:: DELETE /v2.0/qos/alias_dscp_marking_rules/{dscp_rule_id} Please refer to `Delete DSCP marking rule <#delete-dscp-marking-rule>`__ @@ -1045,7 +1045,7 @@ for more information on the request, response and return codes. Show minimum bandwidth rule details alias ========================================= -.. rest_method:: GET /v2.0/qos/minimum_bandwidth_rules/{rule_id} +.. rest_method:: GET /v2.0/qos/alias_minimum_bandwidth_rules/{rule_id} Please refer to `Show minimum bandwidth rule details <#show-minimum-bandwidth-rule-details>`__ @@ -1054,7 +1054,7 @@ for more information on the request, response and return codes. Update minimum bandwidth rule alias =================================== -.. rest_method:: PUT /v2.0/qos/minimum_bandwidth_rules/{rule_id} +.. rest_method:: PUT /v2.0/qos/alias_minimum_bandwidth_rules/{rule_id} Please refer to `Update minimum bandwidth rule <#update-minimum-bandwidth-rule>`__ @@ -1063,7 +1063,7 @@ for more information on the request, response and return codes. Delete minimum bandwidth rule alias =================================== -.. rest_method:: DELETE /v2.0/qos/minimum_bandwidth_rules/{rule_id} +.. rest_method:: DELETE /v2.0/qos/alias_minimum_bandwidth_rules/{rule_id} Please refer to `Delete minimum bandwidth rule <#delete-minimum-bandwidth-rule>`__ diff --git a/neutron_lib/api/definitions/qos_rules_alias.py b/neutron_lib/api/definitions/qos_rules_alias.py index 5e23413c1..c95288570 100644 --- a/neutron_lib/api/definitions/qos_rules_alias.py +++ b/neutron_lib/api/definitions/qos_rules_alias.py @@ -18,6 +18,10 @@ from neutron_lib.db import constants as db_const from neutron_lib.services.qos import constants as q_const +BANDWIDTH_LIMIT_RULES_ALIAS = "alias_bandwidth_limit_rules" +DSCP_MARKING_RULES_ALIAS = 'alias_dscp_marking_rules' +MIN_BANDWIDTH_RULES_ALIAS = 'alias_minimum_bandwidth_rules' + _QOS_RULE_COMMON_FIELDS = { 'id': { 'allow_post': False, 'allow_put': False, @@ -43,7 +47,7 @@ DESCRIPTION = ('API to enable GET, PUT and DELETE operations on QoS policy ' 'rules without specifying policy ID') UPDATED_TIMESTAMP = '2018-10-07T10:00:00-00:00' RESOURCE_ATTRIBUTE_MAP = { - qos.BANDWIDTH_LIMIT_RULES: dict( + BANDWIDTH_LIMIT_RULES_ALIAS: dict( _QOS_RULE_COMMON_FIELDS, **{q_const.MAX_KBPS: { 'allow_post': False, 'allow_put': True, @@ -54,7 +58,7 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': { 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE] } - }, + }, q_const.DIRECTION: { 'allow_post': False, 'allow_put': True, @@ -65,7 +69,7 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': { 'type:values': constants.VALID_DIRECTIONS } - }, + }, q_const.MAX_BURST: { 'allow_post': False, 'allow_put': True, 'is_visible': True, 'default': 0, @@ -75,8 +79,8 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': { 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE] } - }}), - qos.DSCP_MARKING_RULES: dict( + }}), + DSCP_MARKING_RULES_ALIAS: dict( _QOS_RULE_COMMON_FIELDS, **{q_const.DSCP_MARK: { 'allow_post': False, 'allow_put': True, @@ -87,8 +91,8 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': { 'type:values': constants.VALID_DSCP_MARKS } - }}), - qos.MIN_BANDWIDTH_RULES: dict( + }}), + MIN_BANDWIDTH_RULES_ALIAS: dict( _QOS_RULE_COMMON_FIELDS, **{q_const.MIN_KBPS: { 'allow_post': False, 'allow_put': True, @@ -99,7 +103,7 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': { 'type:range': [0, db_const.DB_INTEGER_MAX_VALUE] } - }, + }, q_const.DIRECTION: { 'allow_post': False, 'allow_put': True, 'is_visible': True, 'default': constants.EGRESS_DIRECTION, @@ -108,7 +112,9 @@ RESOURCE_ATTRIBUTE_MAP = { 'validate': { 'type:values': constants.VALID_DIRECTIONS } - }}) + } + } + ) } SUB_RESOURCE_ATTRIBUTE_MAP = {} ACTION_MAP = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_qos_rules_alias.py b/neutron_lib/tests/unit/api/definitions/test_qos_rules_alias.py index 9fac32b34..1421a93ed 100644 --- a/neutron_lib/tests/unit/api/definitions/test_qos_rules_alias.py +++ b/neutron_lib/tests/unit/api/definitions/test_qos_rules_alias.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from neutron_lib.api.definitions import qos from neutron_lib.api.definitions import qos_rules_alias from neutron_lib.services.qos import constants as q_const from neutron_lib.tests.unit.api.definitions import base @@ -18,9 +17,9 @@ from neutron_lib.tests.unit.api.definitions import base class QoSRulesAliasDefinitionTestCase(base.DefinitionBaseTestCase): extension_module = qos_rules_alias - extension_resources = (qos.BANDWIDTH_LIMIT_RULES, - qos.DSCP_MARKING_RULES, - qos.MIN_BANDWIDTH_RULES) + extension_resources = (qos_rules_alias.BANDWIDTH_LIMIT_RULES_ALIAS, + qos_rules_alias.DSCP_MARKING_RULES_ALIAS, + qos_rules_alias.MIN_BANDWIDTH_RULES_ALIAS) extension_attributes = (q_const.DIRECTION, q_const.MAX_BURST, q_const.DSCP_MARK, diff --git a/releasenotes/notes/qos-rules-alias-ext-fix-3f3f7dd21837cfec.yaml b/releasenotes/notes/qos-rules-alias-ext-fix-3f3f7dd21837cfec.yaml new file mode 100644 index 000000000..970d0d1a3 --- /dev/null +++ b/releasenotes/notes/qos-rules-alias-ext-fix-3f3f7dd21837cfec.yaml @@ -0,0 +1,11 @@ +--- +fixes: + - | + The ``qos-rules-alias`` API extension wrongly attempted to re-define + ``bandwidth_limit_rules``, ``dscp_marking_rules`` and + ``minimum_bandwidth_rules`` as first level API resources, leading to + conflicts in the QoS API. We now define ``alias_bandwidth_limit_rules``, + ``alias_dscp_marking_rules`` and ``alias_minimum_bandwidth_rules`` that + will enable users to perform ``GET``, ``PUT`` and ``DELETE`` operations + on the corresponding QoS rules without having to specify the associated + policy ID.