From 03ddc0f6fdae226d8a05d4cb30d795022fa87cf3 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 30 Aug 2024 11:50:55 +0200 Subject: [PATCH] Fix port_hardware_offload_type ML2 extension This patch fixes 2 issues related to that port_hardware_offload_type extension: 1. API extension is now not supported by the ML2 plugin directly so if ml2 extension is not loaded Neutron will not report that API extension is available, 2. Fix error 500 when creating port with hardware_offload_type attribute set but when binding:profile is not set (is of type Sentinel). Conflicts: neutron/plugins/ml2/plugin.py Closes-bug: #2078432 Closes-bug: #2078434 Change-Id: Ib0038dd39d8d210104ee8a70e4519124f09292da (cherry picked from commit fbb7c9ae3d672796b72b796c53f89865ea6b3763) --- neutron/db/port_hardware_offload_type_db.py | 2 +- neutron/plugins/ml2/plugin.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/neutron/db/port_hardware_offload_type_db.py b/neutron/db/port_hardware_offload_type_db.py index 21447e82f6d..9e1975e57ca 100644 --- a/neutron/db/port_hardware_offload_type_db.py +++ b/neutron/db/port_hardware_offload_type_db.py @@ -41,7 +41,7 @@ class PortHardwareOffloadTypeDbMixin(object): if hw_type not in capabilities: capabilities.append(hw_type) data[portbindings.PROFILE]['capabilities'] = capabilities - except KeyError: + except (AttributeError, KeyError): data[portbindings.PROFILE] = {'capabilities': [hw_type]} def _extend_port_dict(self, port_db, result): diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index d6d3ff9ec73..c8a891a9cb6 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -43,7 +43,6 @@ from neutron_lib.api.definitions import network_mtu as mtu_apidef from neutron_lib.api.definitions import network_mtu_writable as mtuw_apidef from neutron_lib.api.definitions import port as port_def from neutron_lib.api.definitions import port_device_profile as pdp_def -from neutron_lib.api.definitions import port_hardware_offload_type as phot_def 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 as pnap_def @@ -246,7 +245,6 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2, port_mac_address_override.ALIAS, sg_default_rules_ext.ALIAS, sg_rules_default_sg.ALIAS, - phot_def.ALIAS, ] # List of agent types for which all binding_failed ports should try to be