From 061a77b4f2d2c8c000b475ee034841a6096c9465 Mon Sep 17 00:00:00 2001 From: Lajos Katona Date: Tue, 17 Jul 2018 17:31:05 +0200 Subject: [PATCH] Introduce Port resource request extension The resources needed by a port are expressed to nova via resource_request extending the port. If the port requested by nova boot has resource_request attribute, that means that placement must enforce the minimum bandwidth requirements. Change-Id: I53a77c4d0aa951480abef614febf810772400621 Needed-By: https://review.openstack.org/584906 Partial-Bug: #1578989 See-Also: https://review.openstack.org/502306 (nova spec) See-Also: https://review.openstack.org/508149 (neutron spec) --- neutron_lib/api/definitions/__init__.py | 2 + neutron_lib/api/definitions/base.py | 1 + .../api/definitions/port_resource_request.py | 42 +++++++++++++++++++ .../definitions/test_port_resource_request.py | 21 ++++++++++ ...ort-resource-request-cb520720cd19523b.yaml | 8 ++++ 5 files changed, 74 insertions(+) create mode 100644 neutron_lib/api/definitions/port_resource_request.py create mode 100644 neutron_lib/tests/unit/api/definitions/test_port_resource_request.py create mode 100644 releasenotes/notes/port-resource-request-cb520720cd19523b.yaml diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 144dab4aa..3dcfb66b3 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -63,6 +63,7 @@ from neutron_lib.api.definitions import network_mtu_writable from neutron_lib.api.definitions import pagination from neutron_lib.api.definitions import port from neutron_lib.api.definitions import port_mac_address_regenerate +from neutron_lib.api.definitions import port_resource_request from neutron_lib.api.definitions import port_security from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import portbindings_extended @@ -152,6 +153,7 @@ _ALL_API_DEFINITIONS = { pagination, port, port_mac_address_regenerate, + port_resource_request, port_security, portbindings, portbindings_extended, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index edddd7c46..132d44342 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -107,6 +107,7 @@ KNOWN_EXTENSIONS = ( 'network-ip-availability', 'network_availability_zone', 'pagination', + 'port-resource-request', 'port-security', 'project-id', 'provider', diff --git a/neutron_lib/api/definitions/port_resource_request.py b/neutron_lib/api/definitions/port_resource_request.py new file mode 100644 index 000000000..9c251ab63 --- /dev/null +++ b/neutron_lib/api/definitions/port_resource_request.py @@ -0,0 +1,42 @@ +# Copyright (c) 2018 Ericsson +# +# 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 import constants + + +ALIAS = 'port-resource-request' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Port Resource Request' +DESCRIPTION = "Expose resource request to Port" +UPDATED_TIMESTAMP = "2018-05-08T10:00:00-00:00" +RESOURCE_NAME = port.RESOURCE_NAME +COLLECTION_NAME = port.COLLECTION_NAME +RESOURCE_REQUEST = 'resource_request' + +RESOURCE_ATTRIBUTE_MAP = { + COLLECTION_NAME: { + RESOURCE_REQUEST: {'allow_post': False, + 'allow_put': False, + 'default': constants.ATTR_NOT_SPECIFIED, + 'is_visible': True} + }, +} + +SUB_RESOURCE_ATTRIBUTE_MAP = None +ACTION_MAP = {} +ACTION_STATUS = {} +REQUIRED_EXTENSIONS = [] +OPTIONAL_EXTENSIONS = [] diff --git a/neutron_lib/tests/unit/api/definitions/test_port_resource_request.py b/neutron_lib/tests/unit/api/definitions/test_port_resource_request.py new file mode 100644 index 000000000..1a87bc284 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_port_resource_request.py @@ -0,0 +1,21 @@ +# Copyright (c) 2018 Ericsson +# +# 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_resource_request +from neutron_lib.tests.unit.api.definitions import base + + +class PortResourceRequestDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = port_resource_request + extension_attributes = (port_resource_request.RESOURCE_REQUEST,) diff --git a/releasenotes/notes/port-resource-request-cb520720cd19523b.yaml b/releasenotes/notes/port-resource-request-cb520720cd19523b.yaml new file mode 100644 index 000000000..6009191d0 --- /dev/null +++ b/releasenotes/notes/port-resource-request-cb520720cd19523b.yaml @@ -0,0 +1,8 @@ +--- +features: + - The new extension ``port-resource-request`` adds the ``resource_request`` + attribute to port responses. This attribute enables Neutron to communicate + to Nova resources needed by the port, such as physnet, VNIC type and + bandwidth. If the port requested by Nova boot has the ``resource_request`` + attribute, then the Nova Scheduler will try to allocate the VM in a host + that can satisfy those requirements.