diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index 52f484d4d..26c3fa74e 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -5054,6 +5054,12 @@ qos_minimum_bandwidth_rule-id: in: body required: true type: string +qos_network_policy_id-port-response: + description: | + The ID of the QoS policy of the network where this port is plugged. + in: body + required: true + type: string qos_policy-name: description: | Human-readable name of the resource. diff --git a/api-ref/source/v2/ports.inc b/api-ref/source/v2/ports.inc index 260f22a83..c80b75cb5 100644 --- a/api-ref/source/v2/ports.inc +++ b/api-ref/source/v2/ports.inc @@ -117,6 +117,13 @@ define QoS policies and associate these to the ports by introducing the ``qos_policy_id`` attribute. The policies should be created before they are associated to the ports. +QoS network policy +================== + +The ``qos-port-network-policy`` extension adds the read only parameter +``qos_network_policy_id`` to the port responses. This parameter contains the +QoS policy ID of the network where this port is plugged. + Regenerate mac address extension ================================ @@ -201,8 +208,9 @@ Response Parameters - network_id: network_id - port_security_enabled: port_security_enabled - project_id: project_id - - revision_number: revision_number + - qos_network_policy_id: qos_network_policy_id-port-response - qos_policy_id: qos_policy_id-port-response + - revision_number: revision_number - resource_request: port-resource - security_groups: port-security_groups - status: port-status @@ -325,8 +333,9 @@ Response Parameters - network_id: network_id - port_security_enabled: port_security_enabled - project_id: project_id - - revision_number: revision_number + - qos_network_policy_id: qos_network_policy_id-port-response - qos_policy_id: qos_policy_id-port-response + - revision_number: revision_number - resource_request: port-resource - security_groups: port-security_groups - status: port-status @@ -460,8 +469,9 @@ Response Parameters - network_id: network_id - port_security_enabled: port_security_enabled - project_id: project_id - - revision_number: revision_number + - qos_network_policy_id: qos_network_policy_id-port-response - qos_policy_id: qos_policy_id-port-response + - revision_number: revision_number - resource_request: port-resource - security_groups: port-security_groups - status: port-status @@ -568,8 +578,9 @@ Response Parameters - network_id: network_id - port_security_enabled: port_security_enabled - project_id: project_id - - revision_number: revision_number + - qos_network_policy_id: qos_network_policy_id-port-response - qos_policy_id: qos_policy_id-port-response + - revision_number: revision_number - resource_request: port-resource - security_groups: port-security_groups - status: port-status @@ -669,8 +680,9 @@ Response Parameters - network_id: network_id - port_security_enabled: port_security_enabled - project_id: project_id - - revision_number: revision_number + - qos_network_policy_id: qos_network_policy_id-port-response - qos_policy_id: qos_policy_id-port-response + - revision_number: revision_number - security_groups: port-security_groups - status: port-status - tags: tags diff --git a/api-ref/source/v2/samples/ports/port-bind-create-response.json b/api-ref/source/v2/samples/ports/port-bind-create-response.json index b7bb88297..8a3b55a28 100644 --- a/api-ref/source/v2/samples/ports/port-bind-create-response.json +++ b/api-ref/source/v2/samples/ports/port-bind-create-response.json @@ -59,6 +59,7 @@ "tags": ["tag1,tag2"], "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": true, "resource_request": { diff --git a/api-ref/source/v2/samples/ports/port-bind-show-response.json b/api-ref/source/v2/samples/ports/port-bind-show-response.json index ce5e23be7..c2ce9b846 100644 --- a/api-ref/source/v2/samples/ports/port-bind-show-response.json +++ b/api-ref/source/v2/samples/ports/port-bind-show-response.json @@ -49,6 +49,7 @@ "tags": ["tag1,tag2"], "tenant_id": "7e02058126cc4950b75f9970368ba177", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "resource_request": { "required": ["CUSTOM_PHYSNET_PUBLIC", "CUSTOM_VNIC_TYPE_NORMAL"], diff --git a/api-ref/source/v2/samples/ports/port-bind-update-response.json b/api-ref/source/v2/samples/ports/port-bind-update-response.json index d4c92db40..bb94aa6f9 100644 --- a/api-ref/source/v2/samples/ports/port-bind-update-response.json +++ b/api-ref/source/v2/samples/ports/port-bind-update-response.json @@ -46,6 +46,7 @@ "tags": ["tag1,tag2"], "tenant_id": "522eda8d23124b25bf03fe44f1986b74", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": false, "resource_request": { diff --git a/api-ref/source/v2/samples/ports/port-create-response.json b/api-ref/source/v2/samples/ports/port-create-response.json index ece2d59a1..ea2d62cc9 100644 --- a/api-ref/source/v2/samples/ports/port-create-response.json +++ b/api-ref/source/v2/samples/ports/port-create-response.json @@ -47,6 +47,7 @@ "tags": ["tag1,tag2"], "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "uplink_status_propagation": false } diff --git a/api-ref/source/v2/samples/ports/port-show-response.json b/api-ref/source/v2/samples/ports/port-show-response.json index 10ca7fe33..1b05171d4 100644 --- a/api-ref/source/v2/samples/ports/port-show-response.json +++ b/api-ref/source/v2/samples/ports/port-show-response.json @@ -40,6 +40,7 @@ "tags": ["tag1,tag2"], "tenant_id": "7e02058126cc4950b75f9970368ba177", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "uplink_status_propagation": false } diff --git a/api-ref/source/v2/samples/ports/port-update-response.json b/api-ref/source/v2/samples/ports/port-update-response.json index 241a8f6a4..b52032396 100644 --- a/api-ref/source/v2/samples/ports/port-update-response.json +++ b/api-ref/source/v2/samples/ports/port-update-response.json @@ -46,6 +46,7 @@ "tags": ["tag1,tag2"], "tenant_id": "522eda8d23124b25bf03fe44f1986b74", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": false, "uplink_status_propagation": false diff --git a/api-ref/source/v2/samples/ports/ports-bind-list-response.json b/api-ref/source/v2/samples/ports/ports-bind-list-response.json index bbd39171a..5f9993d36 100644 --- a/api-ref/source/v2/samples/ports/ports-bind-list-response.json +++ b/api-ref/source/v2/samples/ports/ports-bind-list-response.json @@ -42,6 +42,7 @@ "status": "ACTIVE", "tenant_id": "", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": null, "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "resource_request": { "required": ["CUSTOM_PHYSNET_PUBLIC", "CUSTOM_VNIC_TYPE_NORMAL"], @@ -93,6 +94,7 @@ "status": "ACTIVE", "tenant_id": "d397de8a63f341818f198abb0966f6f3", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": null, "tags": ["tag1,tag2"], "tenant_id": "d397de8a63f341818f198abb0966f6f3", diff --git a/api-ref/source/v2/samples/ports/ports-bulk-create-response.json b/api-ref/source/v2/samples/ports/ports-bulk-create-response.json index 801b2ef1b..1f0ad9acb 100644 --- a/api-ref/source/v2/samples/ports/ports-bulk-create-response.json +++ b/api-ref/source/v2/samples/ports/ports-bulk-create-response.json @@ -37,6 +37,7 @@ "tags": ["tag1,tag2"], "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": null, "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": false, "uplink_status_propagation": false @@ -79,6 +80,7 @@ "tags": ["tag1,tag2"], "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": null, "port_security_enabled": false, "uplink_status_propagation": false diff --git a/api-ref/source/v2/samples/ports/ports-list-response.json b/api-ref/source/v2/samples/ports/ports-list-response.json index 68c554beb..824af849c 100644 --- a/api-ref/source/v2/samples/ports/ports-list-response.json +++ b/api-ref/source/v2/samples/ports/ports-list-response.json @@ -40,6 +40,7 @@ "tags": ["tag1,tag2"], "tenant_id": "", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": "174dd0c1-a4eb-49d4-a807-ae80246d82f4", "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae", "port_security_enabled": false, "uplink_status_propagation": false @@ -84,6 +85,7 @@ "tags": ["tag1,tag2"], "tenant_id": "d397de8a63f341818f198abb0966f6f3", "updated_at": "2016-03-08T20:19:41", + "qos_network_policy_id": null, "qos_policy_id": null, "port_security_enabled": false, "uplink_status_propagation": false diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index a504a90d4..64d783eef 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -83,6 +83,7 @@ from neutron_lib.api.definitions import qos_bw_limit_direction from neutron_lib.api.definitions import qos_bw_minimum_ingress from neutron_lib.api.definitions import qos_default from neutron_lib.api.definitions import qos_gateway_ip +from neutron_lib.api.definitions import qos_port_network_policy from neutron_lib.api.definitions import qos_rule_type_details from neutron_lib.api.definitions import qos_rules_alias from neutron_lib.api.definitions import rbac_security_groups @@ -190,6 +191,7 @@ _ALL_API_DEFINITIONS = { qos_bw_minimum_ingress, qos_default, qos_gateway_ip, + qos_port_network_policy, qos_rule_type_details, qos_rules_alias, rbac_security_groups, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 5897a3c05..32b223e7c 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -124,6 +124,7 @@ KNOWN_EXTENSIONS = ( 'qos', 'qos-bw-limit-direction', 'qos-gateway-ip', + 'qos-port-network-policy', 'qos-rules-alias', 'quotas', 'rbac-policies', diff --git a/neutron_lib/api/definitions/qos_port_network_policy.py b/neutron_lib/api/definitions/qos_port_network_policy.py new file mode 100644 index 000000000..65888cc0c --- /dev/null +++ b/neutron_lib/api/definitions/qos_port_network_policy.py @@ -0,0 +1,41 @@ +# Copyright (c) 2019 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 port as port_apidef +from neutron_lib.api.definitions import qos as qos_apidef +from neutron_lib.services.qos import constants as qos_const + +ALIAS = 'qos-port-network-policy' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'QoS port network policy ID' +DESCRIPTION = 'Adds a the QoS network ID to the port definition' +UPDATED_TIMESTAMP = '2019-11-01T10:00:00-00:00' +RESOURCE_ATTRIBUTE_MAP = { + port_apidef.COLLECTION_NAME: { + qos_const.QOS_POLICY_ID: { + 'allow_post': False, + 'allow_put': False, + 'is_visible': True, + 'default': None, + 'validate': {'type:uuid_or_none': None} + } + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [qos_apidef.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/services/qos/constants.py b/neutron_lib/services/qos/constants.py index e4a14cf1b..b585c8b2c 100644 --- a/neutron_lib/services/qos/constants.py +++ b/neutron_lib/services/qos/constants.py @@ -29,6 +29,7 @@ DIRECTION = "direction" DSCP_MARK = "dscp_mark" QOS_POLICY_ID = 'qos_policy_id' +QOS_NETWORK_POLICY_ID = 'qos_network_policy_id' QOS_PLUGIN = 'qos_plugin' diff --git a/neutron_lib/tests/unit/api/definitions/test_qos_port_network_policy.py b/neutron_lib/tests/unit/api/definitions/test_qos_port_network_policy.py new file mode 100644 index 000000000..1ada20e7b --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_qos_port_network_policy.py @@ -0,0 +1,25 @@ +# Copyright (c) 2019 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 port +from neutron_lib.api.definitions import qos_port_network_policy +from neutron_lib.services.qos import constants as qos_const +from neutron_lib.tests.unit.api.definitions import base + + +class QosPortNetworkPolicyTestCase(base.DefinitionBaseTestCase): + extension_module = qos_port_network_policy + extension_resources = (port.RESOURCE_NAME,) + extension_attributes = (qos_const.QOS_NETWORK_POLICY_ID,) diff --git a/releasenotes/notes/qos-port-network-policy-c64c57cf2ccec725.yaml b/releasenotes/notes/qos-port-network-policy-c64c57cf2ccec725.yaml new file mode 100644 index 000000000..1a5420484 --- /dev/null +++ b/releasenotes/notes/qos-port-network-policy-c64c57cf2ccec725.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Add field ``qos_port_network_policy_id`` to the ``port`` definition. This + read only parameter contains the QoS policy of the network where the port + is plugged.