diff --git a/api-ref/source/v2/networks.inc b/api-ref/source/v2/networks.inc index 1c8b1d8aa..c3d02a601 100644 --- a/api-ref/source/v2/networks.inc +++ b/api-ref/source/v2/networks.inc @@ -40,6 +40,13 @@ The ``external-net`` extension adds the ``router:external`` attribute to networks. This boolean attribute indicates the network has an external routing facility that's not managed by the networking service. +FloatingIP autodelete internal +============================== + +The ``floatingip-autodelete-internal`` shim extension signals that the +update of a network's ``router:external`` attribute from ``true`` to +``false`` autodeletes the unused Floating IPs of that network. + L2 adjacency extension ====================== diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index 4af2e386a..805ed7792 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -5437,7 +5437,9 @@ router-subnet_ids: router:external: description: | Indicates whether the network has an external routing facility that's not - managed by the networking service. + managed by the networking service. If the network is updated from external + to internal the unused floating IPs of this network are automatically + deleted when extension ``floatingip-autodelete-internal`` is present. in: body required: true type: boolean diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 167282494..4296ece5c 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -43,6 +43,7 @@ from neutron_lib.api.definitions import firewall_v2 from neutron_lib.api.definitions import firewallrouterinsertion from neutron_lib.api.definitions import flavors from neutron_lib.api.definitions import floating_ip_port_forwarding +from neutron_lib.api.definitions import floatingip_autodelete_internal from neutron_lib.api.definitions import floatingip_pools from neutron_lib.api.definitions import flowclassifier from neutron_lib.api.definitions import ip_allocation @@ -140,6 +141,7 @@ _ALL_API_DEFINITIONS = { fip_port_details, flavors, floating_ip_port_forwarding, + floatingip_autodelete_internal, floatingip_pools, ip_allocation, ip_substring_port_filtering, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index 2413aa99f..c530b150a 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -99,6 +99,7 @@ KNOWN_EXTENSIONS = ( 'fip-port-details', 'flavors', 'floating-ip-port-forwarding', + 'floatingip-autodelete-internal', 'floatingip-pools', 'ip-substring-filtering', 'l3-ha', diff --git a/neutron_lib/api/definitions/floatingip_autodelete_internal.py b/neutron_lib/api/definitions/floatingip_autodelete_internal.py new file mode 100644 index 000000000..91d70d7b9 --- /dev/null +++ b/neutron_lib/api/definitions/floatingip_autodelete_internal.py @@ -0,0 +1,30 @@ +# Copyright 2019 Ericsson +# +# 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 l3 + + +ALIAS = 'floatingip-autodelete-internal' +IS_SHIM_EXTENSION = True +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Autodelete floating IPs of internal networks' +DESCRIPTION = 'Autodelete unused floating IPs' \ + ' of networks being turned to router:external=False' +UPDATED_TIMESTAMP = '2019-01-24T00:00:00-00:00' +RESOURCE_ATTRIBUTE_MAP = {} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [l3.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_floatingip_autodelete_internal.py b/neutron_lib/tests/unit/api/definitions/test_floatingip_autodelete_internal.py new file mode 100644 index 000000000..de82a1214 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_floatingip_autodelete_internal.py @@ -0,0 +1,20 @@ +# Copyright 2019 Ericsson +# +# 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 floatingip_autodelete_internal +from neutron_lib.tests.unit.api.definitions import base + + +class FloatingIPAutodeleteInternalTestCase(base.DefinitionBaseTestCase): + extension_module = floatingip_autodelete_internal diff --git a/releasenotes/notes/floatingip-autodelete-internal-f08675d8d64d34c6.yaml b/releasenotes/notes/floatingip-autodelete-internal-f08675d8d64d34c6.yaml new file mode 100644 index 000000000..52d8f1ec4 --- /dev/null +++ b/releasenotes/notes/floatingip-autodelete-internal-f08675d8d64d34c6.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + New shim API extension: ``floatingip-autodelete-internal``.