diff --git a/api-ref/source/v2/parameters.yaml b/api-ref/source/v2/parameters.yaml index 990a41736..e4dd9d9a4 100644 --- a/api-ref/source/v2/parameters.yaml +++ b/api-ref/source/v2/parameters.yaml @@ -5532,6 +5532,13 @@ quota: in: body required: true type: object +quota-check-limit: + description: | + A flag used in the ``quota`` update command. If enabled, the Quota engine + will first check the resource usage before applying the new quota limit. + in: body + required: false + type: object quota-detail: description: | A ``quota`` detail object. Each key in the object corresponds to a resource diff --git a/api-ref/source/v2/quotas.inc b/api-ref/source/v2/quotas.inc index 4efa2cc0a..9fe1d2e67 100644 --- a/api-ref/source/v2/quotas.inc +++ b/api-ref/source/v2/quotas.inc @@ -114,6 +114,7 @@ Request - security_group_rule: quota-security_group_rule-request - subnet: quota-subnet-request - subnetpool: quota-subnetpool-request + - check_limit: quota-check-limit Request Example --------------- diff --git a/api-ref/source/v2/samples/quotas/quotas-update-request.json b/api-ref/source/v2/samples/quotas/quotas-update-request.json index 589bc8f5f..31e7aa27c 100644 --- a/api-ref/source/v2/samples/quotas/quotas-update-request.json +++ b/api-ref/source/v2/samples/quotas/quotas-update-request.json @@ -8,6 +8,7 @@ "security_group": 10, "security_group_rule": 100, "subnet": 10, - "subnetpool": -1 + "subnetpool": -1, + "check_limit": "True" } } diff --git a/neutron_lib/api/definitions/__init__.py b/neutron_lib/api/definitions/__init__.py index 8150ee7bb..91326c414 100644 --- a/neutron_lib/api/definitions/__init__.py +++ b/neutron_lib/api/definitions/__init__.py @@ -105,6 +105,7 @@ from neutron_lib.api.definitions import qos_pps_minimum_rule from neutron_lib.api.definitions import qos_pps_rule 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 quota_check_limit from neutron_lib.api.definitions import rbac_address_groups from neutron_lib.api.definitions import rbac_address_scope from neutron_lib.api.definitions import rbac_bgpvpn @@ -240,6 +241,7 @@ _ALL_API_DEFINITIONS = { qos_pps_rule, qos_rule_type_details, qos_rules_alias, + quota_check_limit, rbac_address_groups, rbac_address_scope, rbac_bgpvpn, diff --git a/neutron_lib/api/definitions/base.py b/neutron_lib/api/definitions/base.py index f697b15a6..2a4f1b7e7 100644 --- a/neutron_lib/api/definitions/base.py +++ b/neutron_lib/api/definitions/base.py @@ -145,6 +145,7 @@ KNOWN_EXTENSIONS = ( 'qos-port-network-policy', 'qos-rules-alias', 'quotas', + 'quota-check-limit', 'rbac-address-group', 'rbac-address-scope', 'rbac-bgpvpn', diff --git a/neutron_lib/api/definitions/quota_check_limit.py b/neutron_lib/api/definitions/quota_check_limit.py new file mode 100644 index 000000000..4182a8a8f --- /dev/null +++ b/neutron_lib/api/definitions/quota_check_limit.py @@ -0,0 +1,27 @@ +# Copyright 2021 Red Hat, Inc. +# +# 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. + +ALIAS = 'quota-check-limit' +IS_SHIM_EXTENSION = True +IS_STANDARD_ATTR_EXTENSION = False +NAME = 'Quota engine limit check' +DESCRIPTION = ('Support for checking the resource usage before applying a new ' + 'quota limit') +UPDATED_TIMESTAMP = '2021-09-08T16:00:00-00:00' +RESOURCE_ATTRIBUTE_MAP = {} +SUB_RESOURCE_ATTRIBUTE_MAP = {} +ACTION_MAP = {} +REQUIRED_EXTENSIONS = [] +OPTIONAL_EXTENSIONS = [] +ACTION_STATUS = {} diff --git a/neutron_lib/tests/unit/api/definitions/test_quota_check_limit.py b/neutron_lib/tests/unit/api/definitions/test_quota_check_limit.py new file mode 100644 index 000000000..d7255a6a9 --- /dev/null +++ b/neutron_lib/tests/unit/api/definitions/test_quota_check_limit.py @@ -0,0 +1,20 @@ +# Copyright 2021 Red Hat, Inc. +# +# 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 quota_check_limit +from neutron_lib.tests.unit.api.definitions import base + + +class QuotaCheckLimitDefinitionTestCase(base.DefinitionBaseTestCase): + extension_module = quota_check_limit diff --git a/releasenotes/notes/add-quota-check-limit-api-extension-8e39299644d41f74.yaml b/releasenotes/notes/add-quota-check-limit-api-extension-8e39299644d41f74.yaml new file mode 100644 index 000000000..69535be6e --- /dev/null +++ b/releasenotes/notes/add-quota-check-limit-api-extension-8e39299644d41f74.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add API extension ``quota-check-limit``. This is a shim extension that + indicates if Neutron supports checking the resource usage before applying + a new quota limit. A new API parameter ``check_limit`` is introduced; it + can be used in the ``quota`` update request to enable this check.