From 73059c5c208e88eb61ee75713b5898da542cc8d7 Mon Sep 17 00:00:00 2001 From: Vijendar Komalla Date: Fri, 6 Jan 2017 19:40:45 -0600 Subject: [PATCH] Resource Quota - Add config option to limit clusters Adding config option to limit the max number of clusters allowed per project. This limit is ignored if there is an explicit hard limit set for a project in the 'quotas' table. Change-Id: I8a904de156c10c210e9e72999cdcbc28e374ea71 Partially-Implements: blueprint resource-quota --- magnum/conf/__init__.py | 2 ++ magnum/conf/quota.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 magnum/conf/quota.py diff --git a/magnum/conf/__init__.py b/magnum/conf/__init__.py index 8c0f6f6c36..017fa27221 100644 --- a/magnum/conf/__init__.py +++ b/magnum/conf/__init__.py @@ -33,6 +33,7 @@ from magnum.conf import magnum_client from magnum.conf import neutron from magnum.conf import nova from magnum.conf import paths +from magnum.conf import quota from magnum.conf import rpc from magnum.conf import services from magnum.conf import trust @@ -59,6 +60,7 @@ magnum_client.register_opts(CONF) neutron.register_opts(CONF) nova.register_opts(CONF) paths.register_opts(CONF) +quota.register_opts(CONF) rpc.register_opts(CONF) services.register_opts(CONF) trust.register_opts(CONF) diff --git a/magnum/conf/quota.py b/magnum/conf/quota.py new file mode 100644 index 0000000000..d16097670f --- /dev/null +++ b/magnum/conf/quota.py @@ -0,0 +1,38 @@ +# 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 oslo_config import cfg + +from magnum.i18n import _ + +quotas_group = cfg.OptGroup(name='quotas', + title='Options for quota configuration') + +quotas_def_opts = [ + cfg.IntOpt('max_clusters_per_project', + default=20, + help=_('Max number of clusters allowed per project. Admin can ' + 'override this default quota for a project by setting ' + 'explicit limit in quotas DB table (using /quotas REST ' + 'API endpoint).')), +] + + +def register_opts(conf): + conf.register_group(quotas_group) + conf.register_opts(quotas_def_opts, group=quotas_group) + + +def list_opts(): + return { + quotas_group: quotas_def_opts + }