diff --git a/neutron/common/ovn/extensions.py b/neutron/common/ovn/extensions.py index 3fc8ad77149..155e6d5ef22 100644 --- a/neutron/common/ovn/extensions.py +++ b/neutron/common/ovn/extensions.py @@ -27,6 +27,7 @@ from neutron_lib.api.definitions import extra_dhcp_opt from neutron_lib.api.definitions import extraroute from neutron_lib.api.definitions import filter_validation from neutron_lib.api.definitions import fip_pf_description +from neutron_lib.api.definitions import fip_pf_detail from neutron_lib.api.definitions import fip_pf_port_range from neutron_lib.api.definitions import fip_port_details from neutron_lib.api.definitions import floating_ip_port_forwarding @@ -84,6 +85,7 @@ ML2_SUPPORTED_API_EXTENSIONS_OVN_L3 = [ l3.ALIAS, extraroute.ALIAS, l3_ext_gw_mode.ALIAS, + fip_pf_detail.ALIAS, fip_port_details.ALIAS, floatingip_pools.ALIAS, pagination.ALIAS, diff --git a/neutron/extensions/fip_pf_detail.py b/neutron/extensions/fip_pf_detail.py new file mode 100644 index 00000000000..c4116551aba --- /dev/null +++ b/neutron/extensions/fip_pf_detail.py @@ -0,0 +1,20 @@ +# Copyright (c) 2022 Inspur, 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 fip_pf_detail +from neutron_lib.api import extensions as api_extensions + + +class Fip_pf_detail(api_extensions.APIExtensionDescriptor): + api_definition = fip_pf_detail diff --git a/neutron/services/l3_router/l3_router_plugin.py b/neutron/services/l3_router/l3_router_plugin.py index 463c43b4f4b..7573263bc61 100644 --- a/neutron/services/l3_router/l3_router_plugin.py +++ b/neutron/services/l3_router/l3_router_plugin.py @@ -17,6 +17,7 @@ from neutron_lib.agent import topics from neutron_lib.api.definitions import dvr from neutron_lib.api.definitions import extraroute from neutron_lib.api.definitions import extraroute_atomic +from neutron_lib.api.definitions import fip_pf_detail from neutron_lib.api.definitions import fip_port_details from neutron_lib.api.definitions import floatingip_pools from neutron_lib.api.definitions import l3 as l3_apidef @@ -104,6 +105,7 @@ class L3RouterPlugin(service_base.ServicePluginBase, router_availability_zone.ALIAS, l3_flavors.ALIAS, "qos-fip", fip_port_details.ALIAS, + fip_pf_detail.ALIAS, floatingip_pools.ALIAS, qos_gateway_ip.ALIAS, l3_port_ip_change_not_allowed.ALIAS, diff --git a/neutron/services/portforwarding/pf_plugin.py b/neutron/services/portforwarding/pf_plugin.py index 9e3ff33825e..29a5e260149 100644 --- a/neutron/services/portforwarding/pf_plugin.py +++ b/neutron/services/portforwarding/pf_plugin.py @@ -110,8 +110,9 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase): @staticmethod @resource_extend.extends([l3.FLOATINGIPS]) def _extend_floatingip_dict(result_dict, db): - fields = [apidef.INTERNAL_IP_ADDRESS, apidef.PROTOCOL, - apidef.INTERNAL_PORT, apidef.EXTERNAL_PORT] + fields = [apidef.ID, apidef.INTERNAL_IP_ADDRESS, apidef.PROTOCOL, + apidef.INTERNAL_PORT, apidef.EXTERNAL_PORT, + apidef.INTERNAL_PORT_ID] result_dict[apidef.COLLECTION_NAME] = [] if db.port_forwardings: port_forwarding_result = [] diff --git a/neutron/tests/unit/extensions/test_expose_port_forwarding_in_fip.py b/neutron/tests/unit/extensions/test_expose_port_forwarding_in_fip.py index 6b4ab26eab6..7b2561b53bc 100644 --- a/neutron/tests/unit/extensions/test_expose_port_forwarding_in_fip.py +++ b/neutron/tests/unit/extensions/test_expose_port_forwarding_in_fip.py @@ -49,12 +49,15 @@ class TestL3PorForwardingServicePlugin(test_l3.TestL3NatServicePlugin, def _get_expected(ref): - want_fields = [apidef.INTERNAL_IP_ADDRESS, apidef.PROTOCOL, - apidef.INTERNAL_PORT, apidef.EXTERNAL_PORT] + want_fields = [apidef.ID, apidef.INTERNAL_IP_ADDRESS, apidef.PROTOCOL, + apidef.INTERNAL_PORT, apidef.EXTERNAL_PORT, + apidef.INTERNAL_PORT_ID] expect = { key: value for key, value in ref[apidef.RESOURCE_NAME].items() if key in want_fields} + if apidef.ID not in expect: + expect[apidef.ID] = mock.ANY return expect