diff --git a/api-ref/source/v2/ports.inc b/api-ref/source/v2/ports.inc index d4b596f1c..76911746a 100644 --- a/api-ref/source/v2/ports.inc +++ b/api-ref/source/v2/ports.inc @@ -107,7 +107,8 @@ NUMA affinity policy The NUMA affinity policy extension (``port-numa-affinity-policy``) defines the Nova scheduling strategy according to the network backend NUMA topology. -This parameter could be ``required``, ``preferred``, ``legacy`` or ``None``. +This parameter could be ``required``, ``preferred``, ``legacy``, ``socket`` or +``None``. Port binding extended attributes ================================ diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 46fc62f8f..4bbb399e5 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -96,6 +96,7 @@ from neutron_lib.api.definitions import port_hints from neutron_lib.api.definitions import port_mac_address_override from neutron_lib.api.definitions import port_mac_address_regenerate from neutron_lib.api.definitions import port_numa_affinity_policy +from neutron_lib.api.definitions import port_numa_affinity_policy_socket from neutron_lib.api.definitions import port_resource_request from neutron_lib.api.definitions import port_resource_request_groups from neutron_lib.api.definitions import port_security @@ -252,6 +253,7 @@ _ALL_API_DEFINITIONS = { port_mac_address_override, port_mac_address_regenerate, port_numa_affinity_policy, + port_numa_affinity_policy_socket, port_resource_request, port_resource_request_groups, port_security, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index e75fbe556..2f86f1f0c 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -147,6 +147,8 @@ KNOWN_EXTENSIONS = ( 'quota-check-limit', 'port-hints', 'port-hint-ovs-tx-steering', + 'port-numa-affinity-policy', + 'port-numa-affinity-policy-socket', 'rbac-address-group', 'rbac-address-scope', 'rbac-bgpvpn', diff --git a/neutron_lib/api/definitions/port_numa_affinity_policy.py b/neutron_lib/api/definitions/port_numa_affinity_policy.py index b364c9e28..a9bea650c 100644 --- a/neutron_lib/api/definitions/port_numa_affinity_policy.py +++ b/neutron_lib/api/definitions/port_numa_affinity_policy.py @@ -32,7 +32,10 @@ RESOURCE_ATTRIBUTE_MAP = { 'allow_post': True, 'allow_put': True, 'validate': { - 'type:values': constants.PORT_NUMA_POLICIES + (None, )}, + 'type:values': (constants.PORT_NUMA_POLICY_REQUIRED, + constants.PORT_NUMA_POLICY_PREFERRED, + constants.PORT_NUMA_POLICY_LEGACY, + None)}, 'default': None, 'is_visible': True} }, diff --git a/neutron_lib/api/definitions/port_numa_affinity_policy_socket.py b/neutron_lib/api/definitions/port_numa_affinity_policy_socket.py new file mode 100644 index 000000000..50cdc15af --- /dev/null +++ b/neutron_lib/api/definitions/port_numa_affinity_policy_socket.py @@ -0,0 +1,46 @@ +# Copyright (c) 2024 Red Hat, Inc. +# +# 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 port_numa_affinity_policy +from neutron_lib import constants + + +ALIAS = 'port-numa-affinity-policy-socket' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Port NUMA affinity policy "socket"' +DESCRIPTION = 'Adds "socket" to the supported port NUMA affinity policies' +UPDATED_TIMESTAMP = "2024-02-09T10:00:00-00:00" +RESOURCE_NAME = port.RESOURCE_NAME +COLLECTION_NAME = port.COLLECTION_NAME +NUMA_AFFINITY_POLICY = port_numa_affinity_policy.NUMA_AFFINITY_POLICY + +RESOURCE_ATTRIBUTE_MAP = { + COLLECTION_NAME: { + NUMA_AFFINITY_POLICY: { + 'allow_post': True, + 'allow_put': True, + 'validate': { + 'type:values': constants.PORT_NUMA_POLICIES + (None,)}, + 'default': None, + 'is_visible': True} + }, +} + +SUB_RESOURCE_ATTRIBUTE_MAP = None +ACTION_MAP = {} +ACTION_STATUS = {} +REQUIRED_EXTENSIONS = [port_numa_affinity_policy.ALIAS] +OPTIONAL_EXTENSIONS = [] diff --git a/neutron_lib/constants.py b/neutron_lib/constants.py index 18ed11bee..ef50dbec1 100644 --- a/neutron_lib/constants.py +++ b/neutron_lib/constants.py @@ -703,8 +703,12 @@ RP_PP_INVENTORY_DEFAULTS = ( PORT_NUMA_POLICY_REQUIRED = 'required' PORT_NUMA_POLICY_PREFERRED = 'preferred' PORT_NUMA_POLICY_LEGACY = 'legacy' -PORT_NUMA_POLICIES = (PORT_NUMA_POLICY_REQUIRED, PORT_NUMA_POLICY_PREFERRED, - PORT_NUMA_POLICY_LEGACY) +PORT_NUMA_POLICY_SOCKET = 'socket' +PORT_NUMA_POLICIES = (PORT_NUMA_POLICY_REQUIRED, + PORT_NUMA_POLICY_PREFERRED, + PORT_NUMA_POLICY_LEGACY, + PORT_NUMA_POLICY_SOCKET, + ) # RBAC Sharing Actions ACCESS_SHARED = 'access_as_shared' diff --git a/neutron_lib/tests/unit/api/definitions/test_port_numa_affinity_policy_socket.py b/neutron_lib/tests/unit/api/definitions/test_port_numa_affinity_policy_socket.py new file mode 100644 index 000000000..b414e5c93 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_port_numa_affinity_policy_socket.py @@ -0,0 +1,24 @@ +# Copyright 2024 Red Hat, Inc. +# +# 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_numa_affinity_policy_socket +from neutron_lib.tests.unit.api.definitions import base + + +class PortNumaAffinityPolicySocketDefinitionTestCase( + base.DefinitionBaseTestCase): + extension_module = port_numa_affinity_policy_socket + extension_resources = (port_numa_affinity_policy_socket.COLLECTION_NAME,) + extension_attributes = ( + port_numa_affinity_policy_socket.NUMA_AFFINITY_POLICY,) diff --git a/neutron_lib/tests/unit/objects/test_common_types.py b/neutron_lib/tests/unit/objects/test_common_types.py index 40e9e276a..4d9ae1794 100644 --- a/neutron_lib/tests/unit/objects/test_common_types.py +++ b/neutron_lib/tests/unit/objects/test_common_types.py @@ -337,7 +337,8 @@ class NumaAffinityPoliciesEnumFieldTest(test_base.BaseTestCase, TestField): self.field = common_types.NumaAffinityPoliciesEnumField() good_values = [const.PORT_NUMA_POLICY_REQUIRED, const.PORT_NUMA_POLICY_PREFERRED, - const.PORT_NUMA_POLICY_LEGACY] + const.PORT_NUMA_POLICY_LEGACY, + const.PORT_NUMA_POLICY_SOCKET] self.coerce_good_values = [(val, val) for val in good_values] self.coerce_bad_values = ['foo-invalid-policy'] self.to_primitive_values = self.coerce_good_values diff --git a/releasenotes/notes/port-numa-affinity-policy-socket-5d2ecc3cbbc68702.yaml b/releasenotes/notes/port-numa-affinity-policy-socket-5d2ecc3cbbc68702.yaml new file mode 100644 index 000000000..b97deebb3 --- /dev/null +++ b/releasenotes/notes/port-numa-affinity-policy-socket-5d2ecc3cbbc68702.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + New API definition: ``port-numa-affinity-policy-socket``. This extension + adds a new field, "socket", to the parent API extension + ``port-numa-affinity-policy``. Now the valid values are: None, "required", + "preferred", "legacy" and "socket".