diff --git a/neutron/conf/__init__.py b/neutron/conf/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/neutron/conf/quota.py b/neutron/conf/quota.py new file mode 100644 index 00000000000..a4d68c1c28a --- /dev/null +++ b/neutron/conf/quota.py @@ -0,0 +1,97 @@ +# Copyright 2016 Intel Corporation. +# All Rights Reserved. +# +# 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 neutron._i18n import _ + +QUOTA_DB_MODULE = 'neutron.db.quota.driver' +QUOTA_DB_DRIVER = '%s.DbQuotaDriver' % QUOTA_DB_MODULE +QUOTA_CONF_DRIVER = 'neutron.quota.ConfDriver' +default_quota_items = ['network', 'subnet', 'port'] +QUOTAS_CFG_GROUP = 'QUOTAS' + + +# quota_opts from neutron/quota/__init__.py +# renamed quota_opts to core_quota_opts +core_quota_opts = [ + cfg.ListOpt('quota_items', + default=default_quota_items, + deprecated_for_removal=True, + help=_('Resource name(s) that are supported in quota ' + 'features. This option is now deprecated for ' + 'removal.')), + cfg.IntOpt('default_quota', + default=-1, + help=_('Default number of resource allowed per tenant. ' + 'A negative value means unlimited.')), + cfg.IntOpt('quota_network', + default=10, + help=_('Number of networks allowed per tenant. ' + 'A negative value means unlimited.')), + cfg.IntOpt('quota_subnet', + default=10, + help=_('Number of subnets allowed per tenant, ' + 'A negative value means unlimited.')), + cfg.IntOpt('quota_port', + default=50, + help=_('Number of ports allowed per tenant. ' + 'A negative value means unlimited.')), + cfg.StrOpt('quota_driver', + default=QUOTA_DB_DRIVER, + help=_('Default driver to use for quota checks.')), + cfg.BoolOpt('track_quota_usage', + default=True, + help=_('Keep in track in the database of current resource ' + 'quota usage. Plugins which do not leverage the ' + 'neutron database should set this flag to False.')), +] + +# security_group_quota_opts from neutron/extensions/securitygroup.py +security_group_quota_opts = [ + cfg.IntOpt('quota_security_group', + default=10, + help=_('Number of security groups allowed per tenant. ' + 'A negative value means unlimited.')), + cfg.IntOpt('quota_security_group_rule', + default=100, + help=_('Number of security rules allowed per tenant. ' + 'A negative value means unlimited.')), +] + +# l3_quota_opts from neutron/extensions/l3.py +l3_quota_opts = [ + cfg.IntOpt('quota_router', + default=10, + help=_('Number of routers allowed per tenant. ' + 'A negative value means unlimited.')), + cfg.IntOpt('quota_floatingip', + default=50, + help=_('Number of floating IPs allowed per tenant. ' + 'A negative value means unlimited.')), +] + +# rbac_quota_opts from neutron/extensions/rbac.py +rbac_quota_opts = [ + cfg.IntOpt('quota_rbac_policy', default=10, + deprecated_name='quota_rbac_entry', + help=_('Default number of RBAC entries allowed per tenant. ' + 'A negative value means unlimited.')) +] + + +def register_quota_opts(opts, cfg=cfg.CONF): + cfg.register_opts(opts, QUOTAS_CFG_GROUP) diff --git a/neutron/db/migration/cli.py b/neutron/db/migration/cli.py index 092e608f6d1..908ed0914e7 100644 --- a/neutron/db/migration/cli.py +++ b/neutron/db/migration/cli.py @@ -86,13 +86,6 @@ _core_opts = [ help=_("Enforce using split branches file structure.")) ] -_quota_opts = [ - cfg.StrOpt('quota_driver', - default='', - help=_('Neutron quota driver class'), - deprecated_for_removal=True), -] - _db_opts = [ cfg.StrOpt('connection', deprecated_name='sql_connection', @@ -108,7 +101,6 @@ _db_opts = [ CONF = cfg.ConfigOpts() CONF.register_cli_opts(_core_opts) CONF.register_cli_opts(_db_opts, 'database') -CONF.register_opts(_quota_opts, 'QUOTAS') def do_alembic_command(config, cmd, revision=None, desc=None, **kwargs): diff --git a/neutron/extensions/l3.py b/neutron/extensions/l3.py index a47cab61e7b..84cb12521ef 100644 --- a/neutron/extensions/l3.py +++ b/neutron/extensions/l3.py @@ -17,13 +17,13 @@ import abc from neutron_lib.api import converters from neutron_lib import exceptions as nexception -from oslo_config import cfg import six from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper +from neutron.conf import quota from neutron.pecan_wsgi import controllers from neutron.plugins.common import constants @@ -156,17 +156,8 @@ RESOURCE_ATTRIBUTE_MAP = { }, } -l3_quota_opts = [ - cfg.IntOpt('quota_router', - default=10, - help=_('Number of routers allowed per tenant. ' - 'A negative value means unlimited.')), - cfg.IntOpt('quota_floatingip', - default=50, - help=_('Number of floating IPs allowed per tenant. ' - 'A negative value means unlimited.')), -] -cfg.CONF.register_opts(l3_quota_opts, 'QUOTAS') +# Register the configuration options +quota.register_quota_opts(quota.l3_quota_opts) class L3(extensions.ExtensionDescriptor): diff --git a/neutron/extensions/rbac.py b/neutron/extensions/rbac.py index 18e78c454e0..54adcb96c0d 100644 --- a/neutron/extensions/rbac.py +++ b/neutron/extensions/rbac.py @@ -14,12 +14,12 @@ # under the License. from neutron_lib import exceptions as n_exc -from oslo_config import cfg from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base +from neutron.conf import quota from neutron.db import rbac_db_models from neutron import manager from neutron.quota import resource_registry @@ -78,13 +78,8 @@ RESOURCE_ATTRIBUTE_MAP = { } } -rbac_quota_opts = [ - cfg.IntOpt('quota_rbac_policy', default=10, - deprecated_name='quota_rbac_entry', - help=_('Default number of RBAC entries allowed per tenant. ' - 'A negative value means unlimited.')) -] -cfg.CONF.register_opts(rbac_quota_opts, 'QUOTAS') +# Register the configuration options +quota.register_quota_opts(quota.rbac_quota_opts) class Rbac(extensions.ExtensionDescriptor): diff --git a/neutron/extensions/securitygroup.py b/neutron/extensions/securitygroup.py index 7826fb8c0bb..1596014e264 100644 --- a/neutron/extensions/securitygroup.py +++ b/neutron/extensions/securitygroup.py @@ -19,7 +19,6 @@ import netaddr from neutron_lib.api import validators from neutron_lib import constants as const from neutron_lib import exceptions as nexception -from oslo_config import cfg from oslo_utils import uuidutils import six @@ -29,6 +28,7 @@ from neutron.api.v2 import attributes as attr from neutron.api.v2 import base from neutron.common import constants as n_const from neutron.common import exceptions +from neutron.conf import quota from neutron import manager from neutron.quota import resource_registry @@ -286,17 +286,9 @@ EXTENDED_ATTRIBUTES_2_0 = { 'is_visible': True, 'convert_to': convert_to_uuid_list_or_none, 'default': const.ATTR_NOT_SPECIFIED}}} -security_group_quota_opts = [ - cfg.IntOpt('quota_security_group', - default=10, - help=_('Number of security groups allowed per tenant. ' - 'A negative value means unlimited.')), - cfg.IntOpt('quota_security_group_rule', - default=100, - help=_('Number of security rules allowed per tenant. ' - 'A negative value means unlimited.')), -] -cfg.CONF.register_opts(security_group_quota_opts, 'QUOTAS') + +# Register the configuration options +quota.register_quota_opts(quota.security_group_quota_opts) class Securitygroup(extensions.ExtensionDescriptor): diff --git a/neutron/opts.py b/neutron/opts.py index 23e47962b7c..83254cdd7bb 100644 --- a/neutron/opts.py +++ b/neutron/opts.py @@ -29,6 +29,7 @@ import neutron.agent.linux.ra import neutron.agent.metadata.config import neutron.agent.ovsdb.api import neutron.agent.securitygroups_rpc +import neutron.conf.quota import neutron.db.agents_db import neutron.db.agentschedulers_db import neutron.db.dvr_mac_db @@ -54,7 +55,6 @@ import neutron.plugins.ml2.drivers.type_geneve import neutron.plugins.ml2.drivers.type_gre import neutron.plugins.ml2.drivers.type_vlan import neutron.plugins.ml2.drivers.type_vxlan -import neutron.quota import neutron.service import neutron.services.metering.agents.metering_agent import neutron.services.qos.notification_drivers.manager @@ -101,8 +101,8 @@ def list_extension_opts(): neutron.extensions.allowedaddresspairs.allowed_address_pair_opts), ('quotas', itertools.chain( - neutron.extensions.l3.l3_quota_opts, - neutron.extensions.securitygroup.security_group_quota_opts) + neutron.conf.quota.l3_quota_opts, + neutron.conf.quota.security_group_quota_opts) ) ] @@ -138,7 +138,7 @@ def list_opts(): itertools.chain( neutron.common.config.nova_opts) ), - ('quotas', neutron.quota.quota_opts) + ('quotas', neutron.conf.quota.core_quota_opts) ] diff --git a/neutron/quota/__init__.py b/neutron/quota/__init__.py index b0f263f580c..018954c1365 100644 --- a/neutron/quota/__init__.py +++ b/neutron/quota/__init__.py @@ -26,51 +26,19 @@ import webob from neutron._i18n import _, _LI, _LW from neutron.common import exceptions +from neutron.conf import quota from neutron.db.quota import api as quota_api from neutron.quota import resource_registry - LOG = logging.getLogger(__name__) -QUOTA_DB_MODULE = 'neutron.db.quota.driver' -QUOTA_DB_DRIVER = '%s.DbQuotaDriver' % QUOTA_DB_MODULE -QUOTA_CONF_DRIVER = 'neutron.quota.ConfDriver' -default_quota_items = ['network', 'subnet', 'port'] +QUOTA_DB_MODULE = quota.QUOTA_DB_MODULE +QUOTA_DB_DRIVER = quota.QUOTA_DB_DRIVER +QUOTA_CONF_DRIVER = quota.QUOTA_CONF_DRIVER +default_quota_items = quota.default_quota_items -quota_opts = [ - cfg.ListOpt('quota_items', - default=default_quota_items, - deprecated_for_removal=True, - help=_('Resource name(s) that are supported in quota ' - 'features. This option is now deprecated for ' - 'removal.')), - cfg.IntOpt('default_quota', - default=-1, - help=_('Default number of resource allowed per tenant. ' - 'A negative value means unlimited.')), - cfg.IntOpt('quota_network', - default=10, - help=_('Number of networks allowed per tenant. ' - 'A negative value means unlimited.')), - cfg.IntOpt('quota_subnet', - default=10, - help=_('Number of subnets allowed per tenant, ' - 'A negative value means unlimited.')), - cfg.IntOpt('quota_port', - default=50, - help=_('Number of ports allowed per tenant. ' - 'A negative value means unlimited.')), - cfg.StrOpt('quota_driver', - default=QUOTA_DB_DRIVER, - help=_('Default driver to use for quota checks')), - cfg.BoolOpt('track_quota_usage', - default=True, - help=_('Keep in track in the database of current resource ' - 'quota usage. Plugins which do not leverage the ' - 'neutron database should set this flag to False')), -] # Register the configuration options -cfg.CONF.register_opts(quota_opts, 'QUOTAS') +quota.register_quota_opts(quota.core_quota_opts) class ConfDriver(object):