Merge "Add port-ranges on portforwarding api"

This commit is contained in:
Zuul 2021-04-09 09:03:37 +00:00 committed by Gerrit Code Review
commit 968b979c2a
7 changed files with 151 additions and 5 deletions

View File

@ -7,6 +7,17 @@ Floating IPs port forwarding
Lists, creates, shows details for, updates, and deletes floating IPs port
forwardings.
Port forwarding with port ranges
=========================================
The ``floating-ip-port-forwarding-port-ranges`` extension adds the new
attributes ``internal_port_range`` and ``external_port_range`` to the
floating IP port forwardings. The value of these new attributes should be
a string that represents a colon separated port range. You can not use the
attributes ``internal_port_range`` and ``external_port_range`` with the
attributes ``internal_port`` and ``external_port`` in the same request.
Port forwarding rule description
=========================================
@ -49,7 +60,9 @@ Response Parameters
- internal_port_id: internal_port_id
- internal_ip_address: internal_ip_address-response
- internal_port: internal_port
- internal_port_range: internal_port_range
- external_port: external_port
- external_port_range: external_port_range
- protocol: fip_port_forwarding_protocol-body
- description: fip_port_forwarding-description
@ -82,7 +95,9 @@ Request
- internal_port_id: internal_port_id-update
- internal_ip_address: internal_ip_address
- internal_port: internal_port-update
- internal_port_range: internal_port_range
- external_port: external_port-update
- external_port_range: external_port_range
- protocol: fip_port_forwarding_protocol-update
Request Example
@ -101,7 +116,9 @@ Response Parameters
- internal_port_id: internal_port_id
- internal_ip_address: internal_ip_address-response
- internal_port: internal_port
- internal_port_range: internal_port_range
- external_port: external_port
- external_port_range: external_port_range
- protocol: fip_port_forwarding_protocol-body
- description: fip_port_forwarding-description
@ -164,6 +181,7 @@ Request
- id: id-query
- internal_port_id: internal_port_id-query
- external_port: external_port-query
- external_port_range: external_port_range-query
- protocol: fip_port_forwarding_protocol-query
- sort_key: fip_port_forwarding-sort_key
- sort_dir: sort_dir
@ -179,7 +197,9 @@ Response Parameters
- internal_port_id: internal_port_id
- internal_ip_address: internal_ip_address-response
- internal_port: internal_port
- internal_port_range: internal_port_range
- external_port: external_port
- external_port_range: external_port_range
- protocol: fip_port_forwarding_protocol-body
- description: fip_port_forwarding-description
@ -210,7 +230,9 @@ Request
- internal_port_id: internal_port_id
- internal_ip_address: internal_ip_address
- internal_port: internal_port
- internal_port_range: internal_port_range
- external_port: external_port
- external_port_range: external_port_range
- protocol: fip_port_forwarding_protocol-body
- description: fip_port_forwarding-description
@ -230,7 +252,9 @@ Response Parameters
- internal_port_id: internal_port_id
- internal_ip_address: internal_ip_address-response
- internal_port: internal_port
- internal_port_range: internal_port_range
- external_port: external_port
- external_port_range: external_port_range
- protocol: fip_port_forwarding_protocol-body
- description: fip_port_forwarding-description

View File

@ -485,6 +485,13 @@ external_port-query:
in: query
required: false
type: integer
external_port_range-query:
description: |
Filter the list result by the TCP/UDP/other protocol port range of the
floating IP.
in: query
required: false
type: string
fields:
description: |
The fields that you want the server to return.
@ -506,6 +513,7 @@ fip_port_forwarding-sort_key:
- ``id``
- ``internal_port_id``
- ``external_port``
- ``external_port_range``
- ``protocol``
in: query
required: false
@ -2546,7 +2554,7 @@ external_port:
The TCP/UDP/other protocol port number of the port forwarding's floating IP
address.
in: body
required: true
required: false
type: integer
external_port-update:
description: |
@ -2555,6 +2563,13 @@ external_port-update:
in: body
required: false
type: integer
external_port_range:
description: |
The TCP/UDP/other protocol port range of the port forwarding's floating IP
address.
in: body
required: false
type: string
external_v4_ip:
description: |
Read-only external (public) IPv4 address that is
@ -3275,9 +3290,10 @@ floatingip-port_forwardings:
floating IP has multiple port forwarding resources, this field has
multiple entries. Each entry consists of network IP protocol
(``protocol``), the fixed IP address of internal neutron port
(``internal_ip_address``), the TCP or UDP port used by internal
neutron port (``internal_port``) and the TCP or UDP port used by
floating IP (``external_port``).
(``internal_ip_address``), the TCP or UDP port or port range used by
internal neutron port (``internal_port``) or (``internal_port_range``)
and the TCP or UDP port or port range used by floating IP
(``external_port``) or (``external_port_range``).
in: body
required: true
type: array
@ -3478,7 +3494,7 @@ internal_port:
The TCP/UDP/other protocol port number of the Neutron port fixed IP
address associated to the floating ip port forwarding.
in: body
required: true
required: false
type: integer
internal_port-update:
description: |
@ -3499,6 +3515,13 @@ internal_port_id-update:
in: body
required: false
type: string
internal_port_range:
description: |
The TCP/UDP/other protocol port range of the Neutron port fixed IP
address associated to the floating ip port forwarding.
in: body
required: false
type: string
interval:
description: |
The dead peer detection (DPD) interval, in

View File

@ -17,6 +17,15 @@
"external_port": 2230,
"description": "",
"id": "e0a0274e-4d19-4eab-9e12-9e77a8caf3ea"
},
{
"protocol": "tcp",
"internal_ip_address": "10.0.0.12",
"internal_port_range": "80:90",
"internal_port_id": "2057ec54-8be2-11eb-8dcd-0242ac130003",
"external_port_range": "8080:8090",
"description": "using port ranges",
"id": "0f23a90a-8be2-11eb-8dcd-0242ac130003"
}
]
}

View File

@ -43,6 +43,7 @@ from neutron_lib.api.definitions import extraroute_atomic
from neutron_lib.api.definitions import filter_validation
from neutron_lib.api.definitions import fip64
from neutron_lib.api.definitions import fip_pf_description
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 firewall_v2
from neutron_lib.api.definitions import flavors
@ -165,6 +166,7 @@ _ALL_API_DEFINITIONS = {
fip_port_details,
flavors,
floating_ip_port_forwarding,
fip_pf_port_range,
fip_pf_description,
floatingip_autodelete_internal,
floatingip_pools,

View File

@ -0,0 +1,54 @@
# 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 pfw_desc
from neutron_lib.api.definitions import floating_ip_port_forwarding as pfw
ALIAS = 'floating-ip-port-forwarding-port-ranges'
IS_SHIM_EXTENSION = False
IS_STANDARD_ATTR_EXTENSION = False
NAME = 'Floating IP Port Forwarding support port ranges'
DESCRIPTION = 'Add suport to port ranges'
UPDATED_TIMESTAMP = '2020-07-01T10:00:00-00:00'
EXTERNAL_PORT_RANGE = 'external_port_range'
INTERNAL_PORT_RANGE = 'internal_port_range'
RESOURCE_ATTRIBUTE_MAP = {}
SUB_RESOURCE_ATTRIBUTE_MAP = {
pfw.COLLECTION_NAME: {
'parameters': {
EXTERNAL_PORT_RANGE: {
'allow_post': True, 'allow_put': True,
'validate': {'type:port_range': None},
'is_visible': True,
'is_sort_key': True,
'is_filter': True},
INTERNAL_PORT_RANGE: {
'allow_post': True, 'allow_put': True,
'validate': {'type:port_range': None},
'is_visible': True},
pfw.EXTERNAL_PORT: {
'allow_post': True, 'allow_put': True,
'validate': {'type:range_or_none': [1, 65535]},
'is_visible': True,
'is_sort_key': True,
'is_filter': True},
pfw.INTERNAL_PORT: {
'allow_post': True, 'allow_put': True,
'validate': {'type:range_or_none': [1, 65535]},
'is_visible': True},
}
}
}
ACTION_MAP = {}
REQUIRED_EXTENSIONS = [pfw.ALIAS]
OPTIONAL_EXTENSIONS = [pfw_desc.ALIAS]
ACTION_STATUS = {}

View File

@ -0,0 +1,24 @@
# 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_port_range as pf_port_range
from neutron_lib.api.definitions import floating_ip_port_forwarding as fip_pf
from neutron_lib.tests.unit.api.definitions import base
class FipPortForwardingPortRangeTestCase(base.DefinitionBaseTestCase):
extension_module = pf_port_range
extension_subresources = (fip_pf.COLLECTION_NAME,)
extension_attributes = (pf_port_range.EXTERNAL_PORT_RANGE,
pf_port_range.INTERNAL_PORT_RANGE,
fip_pf.EXTERNAL_PORT,
fip_pf.INTERNAL_PORT,)

View File

@ -0,0 +1,10 @@
---
features:
- |
Add new fields ``internal_port_range`` and ``external_port_range`` to
allow users to create port forwardings using port ranges instead of
creating the ports rules one by one.
Update fields ``internal_port`` and ``external_port`` in floating ip
portforwardings to be optional, as now you can chose between using them
or the ``internal_port_range`` and ``external_port_range`` fields.