Add fip_pf_description extension to be supported by service plugin
In [1] new api extension "fip_pf_description" was introduced but it wasn't added to the list of supported extensions by port_forwarding service plugin. Because of that "description" attribute was unknown for the port_forwarding resource. Now this new api extension is added and supported by pf plugin. [1] https://review.opendev.org/#/c/670930/ Closes-Bug: #1866560 Partially-implements: bp/fip-pf-description Depends-On: https://review.opendev.org/#/c/711856/ Change-Id: Ibf42a4d276d0141d66ae6e88aa9fbc291eaa4f82
This commit is contained in:
parent
a27081636b
commit
4912d11b34
|
@ -0,0 +1,20 @@
|
||||||
|
#
|
||||||
|
# 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_description as apidef
|
||||||
|
from neutron_lib.api import extensions
|
||||||
|
|
||||||
|
|
||||||
|
class Fip_pf_description(extensions.APIExtensionDescriptor):
|
||||||
|
|
||||||
|
api_definition = apidef
|
|
@ -17,6 +17,7 @@ import collections
|
||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from neutron_lib.api.definitions import expose_port_forwarding_in_fip
|
from neutron_lib.api.definitions import expose_port_forwarding_in_fip
|
||||||
|
from neutron_lib.api.definitions import fip_pf_description
|
||||||
from neutron_lib.api.definitions import floating_ip_port_forwarding as apidef
|
from neutron_lib.api.definitions import floating_ip_port_forwarding as apidef
|
||||||
from neutron_lib.api.definitions import l3
|
from neutron_lib.api.definitions import l3
|
||||||
from neutron_lib.callbacks import events
|
from neutron_lib.callbacks import events
|
||||||
|
@ -61,7 +62,8 @@ class PortForwardingPlugin(fip_pf.PortForwardingPluginBase):
|
||||||
required_service_plugins = ['router']
|
required_service_plugins = ['router']
|
||||||
|
|
||||||
supported_extension_aliases = [apidef.ALIAS,
|
supported_extension_aliases = [apidef.ALIAS,
|
||||||
expose_port_forwarding_in_fip.ALIAS]
|
expose_port_forwarding_in_fip.ALIAS,
|
||||||
|
fip_pf_description.ALIAS]
|
||||||
|
|
||||||
__native_pagination_support = True
|
__native_pagination_support = True
|
||||||
__native_sorting_support = True
|
__native_sorting_support = True
|
||||||
|
|
|
@ -46,7 +46,8 @@ class FloatingIPPorForwardingTestCase(test_l3.L3BaseForIntTests,
|
||||||
protocol,
|
protocol,
|
||||||
internal_ip_address,
|
internal_ip_address,
|
||||||
internal_port_id,
|
internal_port_id,
|
||||||
tenant_id=None):
|
tenant_id=None,
|
||||||
|
description=None):
|
||||||
tenant_id = tenant_id or _uuid()
|
tenant_id = tenant_id or _uuid()
|
||||||
data = {'port_forwarding': {
|
data = {'port_forwarding': {
|
||||||
"external_port": external_port,
|
"external_port": external_port,
|
||||||
|
@ -56,6 +57,9 @@ class FloatingIPPorForwardingTestCase(test_l3.L3BaseForIntTests,
|
||||||
"internal_port_id": internal_port_id}
|
"internal_port_id": internal_port_id}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if description:
|
||||||
|
data['port_forwarding']['description'] = description
|
||||||
|
|
||||||
fip_pf_req = self._req(
|
fip_pf_req = self._req(
|
||||||
'POST', 'floatingips', data,
|
'POST', 'floatingips', data,
|
||||||
fmt or self.fmt, id=floating_ip_id,
|
fmt or self.fmt, id=floating_ip_id,
|
||||||
|
@ -100,3 +104,34 @@ class FloatingIPPorForwardingTestCase(test_l3.L3BaseForIntTests,
|
||||||
port['port']['fixed_ips'][0]['ip_address'],
|
port['port']['fixed_ips'][0]['ip_address'],
|
||||||
port['port']['id'])
|
port['port']['id'])
|
||||||
self.assertEqual(exc.HTTPBadRequest.code, res.status_int)
|
self.assertEqual(exc.HTTPBadRequest.code, res.status_int)
|
||||||
|
|
||||||
|
def test_create_floatingip_port_forwarding_with_description(self):
|
||||||
|
with self.network() as ext_net:
|
||||||
|
network_id = ext_net['network']['id']
|
||||||
|
self._set_net_external(network_id)
|
||||||
|
with self.subnet(ext_net, cidr='10.10.10.0/24'), \
|
||||||
|
self.router() as router, \
|
||||||
|
self.subnet(cidr='11.0.0.0/24') as private_subnet, \
|
||||||
|
self.port(private_subnet) as port:
|
||||||
|
self._add_external_gateway_to_router(
|
||||||
|
router['router']['id'],
|
||||||
|
network_id)
|
||||||
|
self._router_interface_action(
|
||||||
|
'add', router['router']['id'],
|
||||||
|
private_subnet['subnet']['id'],
|
||||||
|
None)
|
||||||
|
fip = self._make_floatingip(
|
||||||
|
self.fmt,
|
||||||
|
network_id)
|
||||||
|
self.assertIsNone(fip['floatingip'].get('port_id'))
|
||||||
|
res = self._create_fip_port_forwarding(
|
||||||
|
self.fmt, fip['floatingip']['id'],
|
||||||
|
2222, 22,
|
||||||
|
'tcp',
|
||||||
|
port['port']['fixed_ips'][0]['ip_address'],
|
||||||
|
port['port']['id'],
|
||||||
|
description="blablablabla")
|
||||||
|
self.assertEqual(exc.HTTPCreated.code, res.status_int)
|
||||||
|
pf_body = self.deserialize(self.fmt, res)
|
||||||
|
self.assertEqual(
|
||||||
|
"blablablabla", pf_body['port_forwarding']['description'])
|
||||||
|
|
Loading…
Reference in New Issue