diff --git a/api-ref/source/v2/networks.inc b/api-ref/source/v2/networks.inc index 19298272a..3273fcd46 100644 --- a/api-ref/source/v2/networks.inc +++ b/api-ref/source/v2/networks.inc @@ -47,6 +47,14 @@ 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. +HA extension +============ + +The ``network-ha`` extension allows to pass a boolean parameter during the +network creation. If ``true`` is passed, a ``ha_router_networks`` database +register will be created along with the ``network`` register. This field is +not visible and, initially, not meant to be supported in the CLI. + L2 adjacency extension ====================== diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index 579244918..640cf9878 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -4768,6 +4768,12 @@ network-admin_state_up-request: in: body required: false type: boolean +network-ha: + description: | + The high availability input flag when creating a network. + in: body + required: false + type: boolean network-id: description: | The ID of the network. diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index cecb501b0..deec31936 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -80,6 +80,7 @@ from neutron_lib.api.definitions import multiprovidernet from neutron_lib.api.definitions import network from neutron_lib.api.definitions import network_availability_zone from neutron_lib.api.definitions import network_cascade_delete +from neutron_lib.api.definitions import network_ha from neutron_lib.api.definitions import network_ip_availability from neutron_lib.api.definitions import network_mtu from neutron_lib.api.definitions import network_mtu_writable @@ -228,6 +229,7 @@ _ALL_API_DEFINITIONS = { network, network_availability_zone, network_cascade_delete, + network_ha, network_ip_availability, network_mtu, network_mtu_writable, diff --git a/neutron_lib/api/definitions/network_ha.py b/neutron_lib/api/definitions/network_ha.py new file mode 100644 index 000000000..4fde6f3ce --- /dev/null +++ b/neutron_lib/api/definitions/network_ha.py @@ -0,0 +1,43 @@ +# 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 l3 +from neutron_lib.api.definitions import network + +ALIAS = 'network_ha' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Network HA creation flag' +API_PREFIX = '' +DESCRIPTION = 'Network high availability creation flag.' +UPDATED_TIMESTAMP = '2023-04-27T10:00:00-00:00' +RESOURCE_NAME = network.RESOURCE_NAME +COLLECTION_NAME = network.COLLECTION_NAME +HA = 'ha' +RESOURCE_ATTRIBUTE_MAP = { + COLLECTION_NAME: { + HA: { + 'allow_post': True, + 'allow_put': False, + 'is_visible': False, + 'default': False, + 'convert_to': converters.convert_to_boolean, + }, + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [l3.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/db/model_base.py b/neutron_lib/db/model_base.py index 699084a65..23300d38d 100644 --- a/neutron_lib/db/model_base.py +++ b/neutron_lib/db/model_base.py @@ -62,6 +62,14 @@ class HasProjectPrimaryKey(HasProject): nullable=False, primary_key=True) +class HasProjectPrimaryUniqueKey(HasProject): + """Project mixin, add to subclasses that have a user.""" + + # NOTE: project_id is just a free form string + project_id = sa.Column(sa.String(db_const.PROJECT_ID_FIELD_SIZE), + nullable=False, primary_key=True, unique=True) + + class HasId(object): """id mixin, add to subclasses that have an id.""" diff --git a/releasenotes/notes/network-ha-e6e0c3202b084762.yaml b/releasenotes/notes/network-ha-e6e0c3202b084762.yaml new file mode 100644 index 000000000..2a6f8f7c4 --- /dev/null +++ b/releasenotes/notes/network-ha-e6e0c3202b084762.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + New API definition: ``network-ha``. This boolean field can be used only + during the network creation. If enabled, the Neutron server will create + a ``ha_router_networks`` register, that binds the project with the network + and represents the only high availability network that can be created per + project.