From 8a9b9211d15a5f2ffe2b0ed42ccfc6fe8764753a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 9 Dec 2021 09:21:19 +0000 Subject: [PATCH] Quota engine to accept --force parameter in limit update Neutron quota engine now accepts "--force" parameter in quota limit update command. This is currently the default behaviour: the quota engine does not check the resource usage before updating the quota limit. However, this is an intermediate step before changing the quota engine behaviour. In Z+ (the exact release is not defined yet), the quota engine will requiere "--force" parameter to set a quota limit regarless of the resource usage. By default, the engine will check it. Partial-Bug: #1953170 Change-Id: Ic1132a731f02109233fb80937791cbe7bc3ca0c5 --- neutron/extensions/quotasv2.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/neutron/extensions/quotasv2.py b/neutron/extensions/quotasv2.py index 242f07ac63d..f84eae0e37c 100644 --- a/neutron/extensions/quotasv2.py +++ b/neutron/extensions/quotasv2.py @@ -131,7 +131,22 @@ class QuotaSetsController(wsgi.Controller): def update(self, request, id, body=None): validate_policy(request.context, "update_quota") - check_limit = body[self._resource_name].pop('check_limit', False) + force = body[self._resource_name].pop('force', None) + check_limit = body[self._resource_name].pop('check_limit', None) + # NOTE(ralonsoh): these warning messages will be removed once + # LP#1953170 is completed and Neutron quota engine accepts "--force" or + # nothing (by default, Neutron quota engine will check the resource + # usage before setting the quota limit). + if force is None and check_limit is None: + warnings.warn('Neutron quota engine will require "--force" ' + 'parameter to set a quota limit without checking ' + 'the resource usage.') + elif check_limit: + warnings.warn('"--check-limit" parameter will not be needed in ' + 'Z+. By default, Neutron quota engine will check ' + 'the resource usage before setting a new quota ' + 'limit. Use "--force" to skip this check.') + if self._update_extended_attributes: self._update_attributes() try: