From d3df1b7e9dd52cb531bd25d7bd5cd0c8935bcae1 Mon Sep 17 00:00:00 2001 From: Boden R Date: Fri, 18 Aug 2017 13:31:31 -0600 Subject: [PATCH] rehome router availability zone extension api def This patch rehomes the router az extension API definition into neutron-lib. UTs and a release note are also included. Change-Id: I8bc54b581c26d8472e38efaaa63741785e07d2b8 --- neutron_lib/api/definitions/__init__.py | 2 + .../definitions/router_availability_zone.py | 44 +++++++++++++++++++ .../test_router_availability_zone.py | 20 +++++++++ ...home-routeraz-apidef-efc5f202e04b8272.yaml | 4 ++ 4 files changed, 70 insertions(+) create mode 100644 neutron_lib/api/definitions/router_availability_zone.py create mode 100644 neutron_lib/tests/unit/api/definitions/test_router_availability_zone.py create mode 100644 releasenotes/notes/rehome-routeraz-apidef-efc5f202e04b8272.yaml diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index e8f6a8800..97b0f113f 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -33,6 +33,7 @@ from neutron_lib.api.definitions import port from neutron_lib.api.definitions import port_security from neutron_lib.api.definitions import portbindings from neutron_lib.api.definitions import provider_net +from neutron_lib.api.definitions import router_availability_zone from neutron_lib.api.definitions import router_interface_fip from neutron_lib.api.definitions import subnet from neutron_lib.api.definitions import subnetpool @@ -64,6 +65,7 @@ _ALL_API_DEFINITIONS = { port_security, portbindings, provider_net, + router_availability_zone, router_interface_fip, subnet, subnetpool, diff --git a/neutron_lib/api/definitions/router_availability_zone.py b/neutron_lib/api/definitions/router_availability_zone.py new file mode 100644 index 000000000..931576ec7 --- /dev/null +++ b/neutron_lib/api/definitions/router_availability_zone.py @@ -0,0 +1,44 @@ +# 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 availability_zone as az +from neutron_lib.api.definitions import l3 + + +ALIAS = 'router_availability_zone' +IS_SHIM_EXTENSION = False +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Router Availability Zone' +API_PREFIX = '' +DESCRIPTION = 'Availability zone support for router.' +UPDATED_TIMESTAMP = '2015-01-01T10:00:00-00:00' +RESOURCE_NAME = l3.ROUTER +COLLECTION_NAME = l3.ROUTERS +RESOURCE_ATTRIBUTE_MAP = { + COLLECTION_NAME: { + az.COLLECTION_NAME: { + 'allow_post': False, 'allow_put': False, + 'is_visible': True + }, + az.AZ_HINTS: { + 'allow_post': True, 'allow_put': False, 'is_visible': True, + 'validate': {'type:availability_zone_hint_list': None}, + 'default': [] + } + } +} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [l3.ALIAS, az.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_router_availability_zone.py b/neutron_lib/tests/unit/api/definitions/test_router_availability_zone.py new file mode 100644 index 000000000..ce67fb2a6 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_router_availability_zone.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 availability_zone as az +from neutron_lib.api.definitions import router_availability_zone +from neutron_lib.tests.unit.api.definitions import base + + +class RouterAZDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = router_availability_zone + extension_attributes = (az.AZ_HINTS, az.COLLECTION_NAME,) diff --git a/releasenotes/notes/rehome-routeraz-apidef-efc5f202e04b8272.yaml b/releasenotes/notes/rehome-routeraz-apidef-efc5f202e04b8272.yaml new file mode 100644 index 000000000..96bdf0dcc --- /dev/null +++ b/releasenotes/notes/rehome-routeraz-apidef-efc5f202e04b8272.yaml @@ -0,0 +1,4 @@ +--- +features: + - Neutron's ``router_availability_zone`` extension API definition is now + available in ``neutron_lib.api.definitions.router_availability_zone``.