[api]adds port_forwarding id when list floatingip
if we list floating ip and want to operate a port forwarding, we cannot call the update 'port forwarding' api, because we don't know the port forwarding id. this patch adds the port forwarding returned contents: 'id' and 'internal_port_id' when list floatingip. Closes-bug: #1971646 Depends-On: https://review.opendev.org/c/openstack/neutron-tempest-plugin/+/840584 Change-Id: Ie1d9169cd07547491144776311d77d49b483d5ae
This commit is contained in:
parent
b7fad3dd35
commit
b534de966b
@ -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,
|
||||
|
20
neutron/extensions/fip_pf_detail.py
Normal file
20
neutron/extensions/fip_pf_detail.py
Normal file
@ -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
|
@ -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,
|
||||
|
@ -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 = []
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user