Add port-ranges on portforwarding api
This patch is the first of a series of patches to implement floating ip port forwarding with port ranges. The specification is defined in: https://github.com/openstack/neutron-specs/blob/master/specs/wallaby/port-forwarding-port-ranges.rst Change-Id: Ief57a797a1b1ed34f1d7ec9d7d9f983451647696 Implements: blueprint floatingips-portforwarding-ranges Related-Bug: #1885921
This commit is contained in:
@@ -7,6 +7,17 @@ Floating IPs port forwarding
|
|||||||
Lists, creates, shows details for, updates, and deletes floating IPs port
|
Lists, creates, shows details for, updates, and deletes floating IPs port
|
||||||
forwardings.
|
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
|
Port forwarding rule description
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
@@ -49,7 +60,9 @@ Response Parameters
|
|||||||
- internal_port_id: internal_port_id
|
- internal_port_id: internal_port_id
|
||||||
- internal_ip_address: internal_ip_address-response
|
- internal_ip_address: internal_ip_address-response
|
||||||
- internal_port: internal_port
|
- internal_port: internal_port
|
||||||
|
- internal_port_range: internal_port_range
|
||||||
- external_port: external_port
|
- external_port: external_port
|
||||||
|
- external_port_range: external_port_range
|
||||||
- protocol: fip_port_forwarding_protocol-body
|
- protocol: fip_port_forwarding_protocol-body
|
||||||
- description: fip_port_forwarding-description
|
- description: fip_port_forwarding-description
|
||||||
|
|
||||||
@@ -82,7 +95,9 @@ Request
|
|||||||
- internal_port_id: internal_port_id-update
|
- internal_port_id: internal_port_id-update
|
||||||
- internal_ip_address: internal_ip_address
|
- internal_ip_address: internal_ip_address
|
||||||
- internal_port: internal_port-update
|
- internal_port: internal_port-update
|
||||||
|
- internal_port_range: internal_port_range
|
||||||
- external_port: external_port-update
|
- external_port: external_port-update
|
||||||
|
- external_port_range: external_port_range
|
||||||
- protocol: fip_port_forwarding_protocol-update
|
- protocol: fip_port_forwarding_protocol-update
|
||||||
|
|
||||||
Request Example
|
Request Example
|
||||||
@@ -101,7 +116,9 @@ Response Parameters
|
|||||||
- internal_port_id: internal_port_id
|
- internal_port_id: internal_port_id
|
||||||
- internal_ip_address: internal_ip_address-response
|
- internal_ip_address: internal_ip_address-response
|
||||||
- internal_port: internal_port
|
- internal_port: internal_port
|
||||||
|
- internal_port_range: internal_port_range
|
||||||
- external_port: external_port
|
- external_port: external_port
|
||||||
|
- external_port_range: external_port_range
|
||||||
- protocol: fip_port_forwarding_protocol-body
|
- protocol: fip_port_forwarding_protocol-body
|
||||||
- description: fip_port_forwarding-description
|
- description: fip_port_forwarding-description
|
||||||
|
|
||||||
@@ -164,6 +181,7 @@ Request
|
|||||||
- id: id-query
|
- id: id-query
|
||||||
- internal_port_id: internal_port_id-query
|
- internal_port_id: internal_port_id-query
|
||||||
- external_port: external_port-query
|
- external_port: external_port-query
|
||||||
|
- external_port_range: external_port_range-query
|
||||||
- protocol: fip_port_forwarding_protocol-query
|
- protocol: fip_port_forwarding_protocol-query
|
||||||
- sort_key: fip_port_forwarding-sort_key
|
- sort_key: fip_port_forwarding-sort_key
|
||||||
- sort_dir: sort_dir
|
- sort_dir: sort_dir
|
||||||
@@ -179,7 +197,9 @@ Response Parameters
|
|||||||
- internal_port_id: internal_port_id
|
- internal_port_id: internal_port_id
|
||||||
- internal_ip_address: internal_ip_address-response
|
- internal_ip_address: internal_ip_address-response
|
||||||
- internal_port: internal_port
|
- internal_port: internal_port
|
||||||
|
- internal_port_range: internal_port_range
|
||||||
- external_port: external_port
|
- external_port: external_port
|
||||||
|
- external_port_range: external_port_range
|
||||||
- protocol: fip_port_forwarding_protocol-body
|
- protocol: fip_port_forwarding_protocol-body
|
||||||
- description: fip_port_forwarding-description
|
- description: fip_port_forwarding-description
|
||||||
|
|
||||||
@@ -210,7 +230,9 @@ Request
|
|||||||
- internal_port_id: internal_port_id
|
- internal_port_id: internal_port_id
|
||||||
- internal_ip_address: internal_ip_address
|
- internal_ip_address: internal_ip_address
|
||||||
- internal_port: internal_port
|
- internal_port: internal_port
|
||||||
|
- internal_port_range: internal_port_range
|
||||||
- external_port: external_port
|
- external_port: external_port
|
||||||
|
- external_port_range: external_port_range
|
||||||
- protocol: fip_port_forwarding_protocol-body
|
- protocol: fip_port_forwarding_protocol-body
|
||||||
- description: fip_port_forwarding-description
|
- description: fip_port_forwarding-description
|
||||||
|
|
||||||
@@ -230,7 +252,9 @@ Response Parameters
|
|||||||
- internal_port_id: internal_port_id
|
- internal_port_id: internal_port_id
|
||||||
- internal_ip_address: internal_ip_address-response
|
- internal_ip_address: internal_ip_address-response
|
||||||
- internal_port: internal_port
|
- internal_port: internal_port
|
||||||
|
- internal_port_range: internal_port_range
|
||||||
- external_port: external_port
|
- external_port: external_port
|
||||||
|
- external_port_range: external_port_range
|
||||||
- protocol: fip_port_forwarding_protocol-body
|
- protocol: fip_port_forwarding_protocol-body
|
||||||
- description: fip_port_forwarding-description
|
- description: fip_port_forwarding-description
|
||||||
|
|
||||||
|
|||||||
@@ -466,6 +466,13 @@ external_port-query:
|
|||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
type: integer
|
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:
|
fields:
|
||||||
description: |
|
description: |
|
||||||
The fields that you want the server to return.
|
The fields that you want the server to return.
|
||||||
@@ -487,6 +494,7 @@ fip_port_forwarding-sort_key:
|
|||||||
- ``id``
|
- ``id``
|
||||||
- ``internal_port_id``
|
- ``internal_port_id``
|
||||||
- ``external_port``
|
- ``external_port``
|
||||||
|
- ``external_port_range``
|
||||||
- ``protocol``
|
- ``protocol``
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
@@ -2481,7 +2489,7 @@ external_port:
|
|||||||
The TCP/UDP/other protocol port number of the port forwarding's floating IP
|
The TCP/UDP/other protocol port number of the port forwarding's floating IP
|
||||||
address.
|
address.
|
||||||
in: body
|
in: body
|
||||||
required: true
|
required: false
|
||||||
type: integer
|
type: integer
|
||||||
external_port-update:
|
external_port-update:
|
||||||
description: |
|
description: |
|
||||||
@@ -2490,6 +2498,13 @@ external_port-update:
|
|||||||
in: body
|
in: body
|
||||||
required: false
|
required: false
|
||||||
type: integer
|
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:
|
external_v4_ip:
|
||||||
description: |
|
description: |
|
||||||
Read-only external (public) IPv4 address that is
|
Read-only external (public) IPv4 address that is
|
||||||
@@ -3210,9 +3225,10 @@ floatingip-port_forwardings:
|
|||||||
floating IP has multiple port forwarding resources, this field has
|
floating IP has multiple port forwarding resources, this field has
|
||||||
multiple entries. Each entry consists of network IP protocol
|
multiple entries. Each entry consists of network IP protocol
|
||||||
(``protocol``), the fixed IP address of internal neutron port
|
(``protocol``), the fixed IP address of internal neutron port
|
||||||
(``internal_ip_address``), the TCP or UDP port used by internal
|
(``internal_ip_address``), the TCP or UDP port or port range used by
|
||||||
neutron port (``internal_port``) and the TCP or UDP port used by
|
internal neutron port (``internal_port``) or (``internal_port_range``)
|
||||||
floating IP (``external_port``).
|
and the TCP or UDP port or port range used by floating IP
|
||||||
|
(``external_port``) or (``external_port_range``).
|
||||||
in: body
|
in: body
|
||||||
required: true
|
required: true
|
||||||
type: array
|
type: array
|
||||||
@@ -3413,7 +3429,7 @@ internal_port:
|
|||||||
The TCP/UDP/other protocol port number of the Neutron port fixed IP
|
The TCP/UDP/other protocol port number of the Neutron port fixed IP
|
||||||
address associated to the floating ip port forwarding.
|
address associated to the floating ip port forwarding.
|
||||||
in: body
|
in: body
|
||||||
required: true
|
required: false
|
||||||
type: integer
|
type: integer
|
||||||
internal_port-update:
|
internal_port-update:
|
||||||
description: |
|
description: |
|
||||||
@@ -3434,6 +3450,13 @@ internal_port_id-update:
|
|||||||
in: body
|
in: body
|
||||||
required: false
|
required: false
|
||||||
type: string
|
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:
|
interval:
|
||||||
description: |
|
description: |
|
||||||
The dead peer detection (DPD) interval, in
|
The dead peer detection (DPD) interval, in
|
||||||
|
|||||||
@@ -17,6 +17,15 @@
|
|||||||
"external_port": 2230,
|
"external_port": 2230,
|
||||||
"description": "",
|
"description": "",
|
||||||
"id": "e0a0274e-4d19-4eab-9e12-9e77a8caf3ea"
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ from neutron_lib.api.definitions import extraroute_atomic
|
|||||||
from neutron_lib.api.definitions import filter_validation
|
from neutron_lib.api.definitions import filter_validation
|
||||||
from neutron_lib.api.definitions import fip64
|
from neutron_lib.api.definitions import fip64
|
||||||
from neutron_lib.api.definitions import fip_pf_description
|
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 fip_port_details
|
||||||
from neutron_lib.api.definitions import firewall_v2
|
from neutron_lib.api.definitions import firewall_v2
|
||||||
from neutron_lib.api.definitions import flavors
|
from neutron_lib.api.definitions import flavors
|
||||||
@@ -155,6 +156,7 @@ _ALL_API_DEFINITIONS = {
|
|||||||
fip_port_details,
|
fip_port_details,
|
||||||
flavors,
|
flavors,
|
||||||
floating_ip_port_forwarding,
|
floating_ip_port_forwarding,
|
||||||
|
fip_pf_port_range,
|
||||||
fip_pf_description,
|
fip_pf_description,
|
||||||
floatingip_autodelete_internal,
|
floatingip_autodelete_internal,
|
||||||
floatingip_pools,
|
floatingip_pools,
|
||||||
|
|||||||
54
neutron_lib/api/definitions/fip_pf_port_range.py
Normal file
54
neutron_lib/api/definitions/fip_pf_port_range.py
Normal 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 = {}
|
||||||
@@ -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,)
|
||||||
@@ -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.
|
||||||
Reference in New Issue
Block a user