From 0828cad81543b68c48e8de7d5e0ba0ac17ab8696 Mon Sep 17 00:00:00 2001 From: Boden R Date: Fri, 4 Aug 2017 13:32:38 -0600 Subject: [PATCH] rehome default subnet pools API def This patch rehomes neutron's default subnet pools extension into neutron-libs API definition layout/structure. UTs and a reno are also included. Change-Id: Ib841f3727e758c0c19c9a4a0acd221ecb4081313 --- neutron_lib/api/definitions/__init__.py | 2 + .../api/definitions/default_subnetpools.py | 41 +++++++++++++++++++ .../definitions/test_default_subnetpools.py | 20 +++++++++ ...e-dftsnetpool-apidef-4de5d75d2a63dec9.yaml | 4 ++ 4 files changed, 67 insertions(+) create mode 100644 neutron_lib/api/definitions/default_subnetpools.py create mode 100644 neutron_lib/tests/unit/api/definitions/test_default_subnetpools.py create mode 100644 releasenotes/notes/rehome-dftsnetpool-apidef-4de5d75d2a63dec9.yaml diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index f732e5b07..9e1463e43 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -16,6 +16,7 @@ from neutron_lib.api.definitions import auto_allocated_topology from neutron_lib.api.definitions import bgpvpn from neutron_lib.api.definitions import bgpvpn_routes_control from neutron_lib.api.definitions import data_plane_status +from neutron_lib.api.definitions import default_subnetpools from neutron_lib.api.definitions import dns from neutron_lib.api.definitions import dns_domain_ports from neutron_lib.api.definitions import extra_dhcp_opt @@ -46,6 +47,7 @@ _ALL_API_DEFINITIONS = { bgpvpn, bgpvpn_routes_control, data_plane_status, + default_subnetpools, dns, dns_domain_ports, extra_dhcp_opt, diff --git a/neutron_lib/api/definitions/default_subnetpools.py b/neutron_lib/api/definitions/default_subnetpools.py new file mode 100644 index 000000000..a4c0bd1b1 --- /dev/null +++ b/neutron_lib/api/definitions/default_subnetpools.py @@ -0,0 +1,41 @@ +# 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 subnet as subnet_def +from neutron_lib import constants + +USE_DEFAULT_SUBNETPOOL = 'use_default_subnetpool' + +ALIAS = 'default-subnetpools' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Default Subnetpools' +API_PREFIX = '' +DESCRIPTION = 'Provides ability to mark and use a subnetpool as the default.' +UPDATED_TIMESTAMP = '2016-02-18T18:00:00-00:00' +RESOURCE_NAME = subnet_def.RESOURCE_NAME +COLLECTION_NAME = subnet_def.COLLECTION_NAME +RESOURCE_ATTRIBUTE_MAP = { + COLLECTION_NAME: { + USE_DEFAULT_SUBNETPOOL: {'allow_post': True, + 'allow_put': False, + 'default': False, + 'convert_to': converters.convert_to_boolean, + 'is_visible': False}, + }, +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [constants.SUBNET_ALLOCATION_EXT_ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_default_subnetpools.py b/neutron_lib/tests/unit/api/definitions/test_default_subnetpools.py new file mode 100644 index 000000000..54e32d830 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_default_subnetpools.py @@ -0,0 +1,20 @@ +# 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 default_subnetpools +from neutron_lib.tests.unit.api.definitions import base + + +class DefaultSubnetPoolsDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = default_subnetpools + extension_resources = () + extension_attributes = (default_subnetpools.USE_DEFAULT_SUBNETPOOL,) diff --git a/releasenotes/notes/rehome-dftsnetpool-apidef-4de5d75d2a63dec9.yaml b/releasenotes/notes/rehome-dftsnetpool-apidef-4de5d75d2a63dec9.yaml new file mode 100644 index 000000000..28e5925cb --- /dev/null +++ b/releasenotes/notes/rehome-dftsnetpool-apidef-4de5d75d2a63dec9.yaml @@ -0,0 +1,4 @@ +--- +features: + - The API definition for neutron extension ``default-subnetpools`` is now + available in ``neutron_lib.api.definitions.default_subnetpools``.