From 7441b091ee13b22376fbfb970b5372d9d6b4a00c Mon Sep 17 00:00:00 2001 From: zhouhenglc Date: Tue, 30 Aug 2022 10:36:38 +0800 Subject: [PATCH] [ovn]Floating IP adds distributed attributes Partial-bug: #1978039 Partially-Implements: blueprint custom-floatingip-distributed Change-Id: I7894c2b5afa11bcb0c78b3525d74bd9345edd361 --- api-ref/source/v2/floatingips.inc | 14 ++++++ api-ref/source/v2/parameters.yaml | 14 ++++++ neutron_lib/api/definitions/__init__.py | 2 + .../api/definitions/fip_distributed.py | 44 +++++++++++++++++++ .../api/definitions/test_fip_distributed.py | 21 +++++++++ ...istributed-extension-ce44e8df264d44b6.yaml | 5 +++ 6 files changed, 100 insertions(+) create mode 100644 neutron_lib/api/definitions/fip_distributed.py create mode 100644 neutron_lib/tests/unit/api/definitions/test_fip_distributed.py create mode 100644 releasenotes/notes/add-fip-distributed-extension-ce44e8df264d44b6.yaml diff --git a/api-ref/source/v2/floatingips.inc b/api-ref/source/v2/floatingips.inc index d55607db1..efc2dfc89 100644 --- a/api-ref/source/v2/floatingips.inc +++ b/api-ref/source/v2/floatingips.inc @@ -10,6 +10,13 @@ attributes to floating IPs allowing them to be specified at creation time. The data in these attributes will be published in an external DNS service when Neutron is configured to integrate with such a service. +Floating IP distributed +======================== + +The ``floating-ip-distributed`` extension adds the ``distributed`` attribute +to the floating IPs. The value of this attribute identify the Floating IP is +distributed or centralized. + Floating IP port details ======================== @@ -97,6 +104,7 @@ Request - project_id: project_id-query - revision_number: revision_number-query - description: description-query + - distributed: fip-distributed-request - floating_network_id: floating_network_id-query - fixed_ip_address: floatingip-fixed_ip_address-query - floating_ip_address: floating_ip_address-query @@ -124,6 +132,7 @@ Response Parameters - updated_at: updated_at_resource - revision_number: revision_number - description: description + - distributed: fip-distributed - dns_domain: dns_domain - dns_name: dns_name - port_details: floating_port_details @@ -216,6 +225,7 @@ Request - floating_ip_address: floating_ip_address-request - port_id: floatingip-port_id-post-request - subnet_id: floatingip-subnet_id + - distributed: fip-distributed-request - description: description-request - dns_domain: dns_domain-request - dns_name: dns_name-request @@ -236,6 +246,7 @@ Response Parameters - router_id: floatingip-router_id - status: floatingip-status - description: description + - distributed: fip-distributed - dns_domain: dns_domain - dns_name: dns_name - port_details: floating_port_details @@ -304,6 +315,7 @@ Response Parameters - router_id: floatingip-router_id - status: floatingip-status - description: description + - distributed: fip-distributed - dns_domain: dns_domain - dns_name: dns_name - port_details: floating_port_details @@ -364,6 +376,7 @@ Request - port_id: floatingip-port_id-put-request - fixed_ip_address: floatingip-fixed_ip_address-request - description: description-request + - distributed: fip-distributed-request Request Example --------------- @@ -396,6 +409,7 @@ Response Parameters - updated_at: updated_at_resource - revision_number: revision_number - description: description + - distributed: fip-distributed - dns_domain: dns_domain - dns_name: dns_name - port_details: floating_port_details diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index 8ac8723a0..fde49d9e0 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -3072,6 +3072,20 @@ extra_dhcp_opts-request: in: body required: false type: array +fip-distributed: + description: | + ``true`` indicates a distributed floatingip. + It is available when ``floating-ip-distributed`` extension is enabled. + in: body + required: true + type: boolean +fip-distributed-request: + description: | + ``true`` indicates a distributed floatingip. + It is available when ``floating-ip-distributed`` extension is enabled. + in: body + required: false + type: boolean fip_port_forwarding: description: | A ``floating IP port forwarding`` object. diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 08dd40ec4..9792f5596 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -46,6 +46,7 @@ from neutron_lib.api.definitions import extraroute 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_distributed 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 @@ -189,6 +190,7 @@ _ALL_API_DEFINITIONS = { filter_validation, fip64, firewall_v2, + fip_distributed, fip_pf_detail, fip_port_details, flavors, diff --git a/neutron_lib/api/definitions/fip_distributed.py b/neutron_lib/api/definitions/fip_distributed.py new file mode 100644 index 000000000..d6aa57c85 --- /dev/null +++ b/neutron_lib/api/definitions/fip_distributed.py @@ -0,0 +1,44 @@ +# 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 import converters +from neutron_lib.api.definitions import dvr +from neutron_lib.api.definitions import l3 +from neutron_lib import constants + + +ALIAS = 'floating-ip-distributed' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Floating IP Distributed Extension' +DESCRIPTION = 'Add distributed attribute to Floating IP resource' +UPDATED_TIMESTAMP = '2022-08-30T10:00:00-00:00' +DISTRIBUTED = 'distributed' +RESOURCE_ATTRIBUTE_MAP = { + l3.FLOATINGIPS: { + DISTRIBUTED: { + 'allow_post': True, + 'allow_put': True, + 'convert_to': converters.convert_to_boolean_if_not_none, + 'default': constants.ATTR_NOT_SPECIFIED, + 'is_visible': True, + 'is_filter': True + } + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [l3.ALIAS, dvr.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_fip_distributed.py b/neutron_lib/tests/unit/api/definitions/test_fip_distributed.py new file mode 100644 index 000000000..9c02749b9 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_fip_distributed.py @@ -0,0 +1,21 @@ +# 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_distributed +from neutron_lib.api.definitions import l3 +from neutron_lib.tests.unit.api.definitions import base + + +class FipDistributedDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = fip_distributed + extension_resources = (l3.FLOATINGIPS,) + extension_attributes = (fip_distributed.DISTRIBUTED,) diff --git a/releasenotes/notes/add-fip-distributed-extension-ce44e8df264d44b6.yaml b/releasenotes/notes/add-fip-distributed-extension-ce44e8df264d44b6.yaml new file mode 100644 index 000000000..1d6e8e3de --- /dev/null +++ b/releasenotes/notes/add-fip-distributed-extension-ce44e8df264d44b6.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Add API extension ``floating-ip-distributed``. This extension + adds ``distributed`` attribute to the Floating IP resource.