diff --git a/api-ref/source/v2/routers.inc b/api-ref/source/v2/routers.inc index 4a4a7e482..6c3444f47 100644 --- a/api-ref/source/v2/routers.inc +++ b/api-ref/source/v2/routers.inc @@ -52,6 +52,17 @@ Resource timestamps The ``standard-attr-timestamp`` extension adds the ``created_at`` and ``updated_at`` attributes to all resources that have standard attributes. +Router admin state down before update extension +=============================================== + +The ``router-admin-state-down-before-update`` extension adds the requirement +that the administrative state of a distributed virtual router (DVR) be set to +DOWN (``admin_state_up=False``) prior to modifying the ``distributed`` +parameter of the router. The API will return an error response code of 400 if +the router's ``distributed`` attribute is modified without first setting the +router's ``admin_state_up=False``. +This extension requires the ``dvr`` extension. + Router availability zone extension ================================== diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 12cf041f6..345ca66c1 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -86,6 +86,7 @@ from neutron_lib.api.definitions import qos_rule_type_details from neutron_lib.api.definitions import qos_rules_alias from neutron_lib.api.definitions import rbac_security_groups from neutron_lib.api.definitions import revisionifmatch +from neutron_lib.api.definitions import router_admin_state_down_before_update from neutron_lib.api.definitions import router_availability_zone from neutron_lib.api.definitions import router_interface_fip from neutron_lib.api.definitions import routerservicetype @@ -191,6 +192,7 @@ _ALL_API_DEFINITIONS = { qos_rules_alias, rbac_security_groups, revisionifmatch, + router_admin_state_down_before_update, router_availability_zone, router_interface_fip, routerservicetype, diff --git a/neutron_lib/api/definitions/router_admin_state_down_before_update.py b/neutron_lib/api/definitions/router_admin_state_down_before_update.py new file mode 100644 index 000000000..49cb19ade --- /dev/null +++ b/neutron_lib/api/definitions/router_admin_state_down_before_update.py @@ -0,0 +1,28 @@ +# 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 dvr as dvr_apidef + +ALIAS = 'router-admin-state-down-before-update' +IS_SHIM_EXTENSION = True +IS_STANDARD_ATTR_EXTENSION = False +NAME = "Enforce Router's Admin State Down Before Update Extension" +DESCRIPTION = ('Ensure that the admin state of a router is DOWN ' + '(admin_state_up=False) before updating the distributed ' + 'attribute') +UPDATED_TIMESTAMP = '2019-07-02T15:56:00' +RESOURCE_ATTRIBUTE_MAP = {} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [dvr_apidef.ALIAS] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_admin_state_down_before_update.py b/neutron_lib/tests/unit/api/definitions/test_admin_state_down_before_update.py new file mode 100644 index 000000000..4f8b6698f --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_admin_state_down_before_update.py @@ -0,0 +1,18 @@ +# 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 router_admin_state_down_before_update +from neutron_lib.tests.unit.api.definitions import base + + +class AdminStateDownToUpdateDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = router_admin_state_down_before_update diff --git a/releasenotes/notes/admin-state-down-before-update-c06fb3a551fe499f.yaml b/releasenotes/notes/admin-state-down-before-update-c06fb3a551fe499f.yaml new file mode 100644 index 000000000..2a74c6549 --- /dev/null +++ b/releasenotes/notes/admin-state-down-before-update-c06fb3a551fe499f.yaml @@ -0,0 +1,5 @@ +--- +features: + - Router API is modified through a regime API extension to neutron-lib that + enforces the admin state of a router be DOWN (admin_state_up=False) prior + to modifying the distributed attribute of the router.