Reference QUOTA OptGoup names in lowercase

To have consistent option group name format across projects,
oslo.config now normalizes all non lowercase group names to lowercase
when loading conf files.
Thus conf files are backwards compatible but option group references
in the code must now use lowercase before we update oslo.config.

This patch replaces all 'QUOTA' references to 'quota'

Change-Id: I74c2a35aea7a52f9586eb598fe52d2cecb1851ef
This commit is contained in:
Zhongyue Luo 2013-05-15 08:36:11 +08:00 committed by Gerrit Code Review
parent 240ba2d007
commit 362bd7fd09
14 changed files with 24 additions and 24 deletions

View File

@ -258,7 +258,7 @@ notification_topics = notifications
#ssl_ca_file = /path/to/cafile #ssl_ca_file = /path/to/cafile
# ======== end of WSGI parameters related to the API server ========== # ======== end of WSGI parameters related to the API server ==========
[QUOTAS] [quotas]
# resource name(s) that are supported in quota features # resource name(s) that are supported in quota features
# quota_items = network,subnet,port # quota_items = network,subnet,port

View File

@ -91,7 +91,7 @@ sql_connection = sqlite://
# sql_idle_timeout = 3600 # sql_idle_timeout = 3600
[QUOTAS] [quotas]
# number of network gateways allowed per tenant, -1 means unlimited # number of network gateways allowed per tenant, -1 means unlimited
# quota_network_gateway = 5 # quota_network_gateway = 5

View File

@ -45,7 +45,7 @@ _db_opts = [
CONF = cfg.ConfigOpts() CONF = cfg.ConfigOpts()
CONF.register_opts(_core_opts) CONF.register_opts(_core_opts)
CONF.register_opts(_db_opts, 'DATABASE') CONF.register_opts(_db_opts, 'DATABASE')
CONF.register_opts(_quota_opts, 'QUOTAS') CONF.register_opts(_quota_opts, 'quotas')
def do_alembic_command(config, cmd, *args, **kwargs): def do_alembic_command(config, cmd, *args, **kwargs):

View File

@ -159,7 +159,7 @@ l3_quota_opts = [
help=_('Number of floating IPs allowed per tenant, ' help=_('Number of floating IPs allowed per tenant, '
'-1 for unlimited')), '-1 for unlimited')),
] ]
cfg.CONF.register_opts(l3_quota_opts, 'QUOTAS') cfg.CONF.register_opts(l3_quota_opts, 'quotas')
class L3(extensions.ExtensionDescriptor): class L3(extensions.ExtensionDescriptor):

View File

@ -43,7 +43,7 @@ class QuotaSetsController(wsgi.Controller):
def __init__(self, plugin): def __init__(self, plugin):
self._resource_name = RESOURCE_NAME self._resource_name = RESOURCE_NAME
self._plugin = plugin self._plugin = plugin
self._driver = importutils.import_class(cfg.CONF.QUOTAS.quota_driver) self._driver = importutils.import_class(cfg.CONF.quotas.quota_driver)
self._update_extended_attributes = True self._update_extended_attributes = True
def _update_attributes(self): def _update_attributes(self):
@ -117,7 +117,7 @@ class Quotasv2(extensions.ExtensionDescriptor):
@classmethod @classmethod
def get_description(cls): def get_description(cls):
description = 'Expose functions for quotas management' description = 'Expose functions for quotas management'
if cfg.CONF.QUOTAS.quota_driver == DB_QUOTA_DRIVER: if cfg.CONF.quotas.quota_driver == DB_QUOTA_DRIVER:
description += ' per tenant' description += ' per tenant'
return description return description

View File

@ -212,7 +212,7 @@ security_group_quota_opts = [
help=_('Number of security rules allowed per tenant, ' help=_('Number of security rules allowed per tenant, '
'-1 for unlimited')), '-1 for unlimited')),
] ]
cfg.CONF.register_opts(security_group_quota_opts, 'QUOTAS') cfg.CONF.register_opts(security_group_quota_opts, 'quotas')
class Securitygroup(extensions.ExtensionDescriptor): class Securitygroup(extensions.ExtensionDescriptor):

View File

@ -22,7 +22,7 @@ core_plugin = quantum.plugins.cisco.network_plugin.PluginV2
# The messaging module to use, defaults to kombu. # The messaging module to use, defaults to kombu.
rpc_backend = quantum.openstack.common.rpc.impl_fake rpc_backend = quantum.openstack.common.rpc.impl_fake
[QUOTAS] [quotas]
# resource name(s) that are supported in quota features # resource name(s) that are supported in quota features
quota_items = network,subnet,port quota_items = network,subnet,port

View File

@ -34,7 +34,7 @@ quota_packet_filter_opts = [
"-1 for unlimited")) "-1 for unlimited"))
] ]
# Register the configuration options # Register the configuration options
cfg.CONF.register_opts(quota_packet_filter_opts, 'QUOTAS') cfg.CONF.register_opts(quota_packet_filter_opts, 'quotas')
PACKET_FILTER_ACTION_REGEX = "(?i)^(allow|accept|drop|deny)$" PACKET_FILTER_ACTION_REGEX = "(?i)^(allow|accept|drop|deny)$"

View File

@ -89,7 +89,7 @@ nw_gw_quota_opts = [
'-1 for unlimited')) '-1 for unlimited'))
] ]
cfg.CONF.register_opts(nw_gw_quota_opts, 'QUOTAS') cfg.CONF.register_opts(nw_gw_quota_opts, 'quotas')
attributes.validators['type:device_list'] = _validate_device_list attributes.validators['type:device_list'] = _validate_device_list

View File

@ -50,7 +50,7 @@ quota_opts = [
help=_('Default driver to use for quota checks')), help=_('Default driver to use for quota checks')),
] ]
# Register the configuration options # Register the configuration options
cfg.CONF.register_opts(quota_opts, 'QUOTAS') cfg.CONF.register_opts(quota_opts, 'quotas')
class ConfDriver(object): class ConfDriver(object):
@ -163,9 +163,9 @@ class BaseResource(object):
@property @property
def default(self): def default(self):
"""Return the default value of the quota.""" """Return the default value of the quota."""
return getattr(cfg.CONF.QUOTAS, return getattr(cfg.CONF.quotas,
self.flag, self.flag,
cfg.CONF.QUOTAS.default_quota) cfg.CONF.quotas.default_quota)
class CountableResource(BaseResource): class CountableResource(BaseResource):
@ -206,7 +206,7 @@ class QuotaEngine(object):
"""Initialize a Quota object.""" """Initialize a Quota object."""
if not quota_driver_class: if not quota_driver_class:
quota_driver_class = cfg.CONF.QUOTAS.quota_driver quota_driver_class = cfg.CONF.quotas.quota_driver
if isinstance(quota_driver_class, basestring): if isinstance(quota_driver_class, basestring):
quota_driver_class = importutils.import_object(quota_driver_class) quota_driver_class = importutils.import_object(quota_driver_class)
@ -306,7 +306,7 @@ def _count_resource(context, plugin, resources, tenant_id):
def register_resources_from_config(): def register_resources_from_config():
resources = [] resources = []
for resource_item in cfg.CONF.QUOTAS.quota_items: for resource_item in cfg.CONF.quotas.quota_items:
resources.append(CountableResource(resource_item, _count_resource, resources.append(CountableResource(resource_item, _count_resource,
'quota_' + resource_item)) 'quota_' + resource_item))
QUOTAS.register_resources(resources) QUOTAS.register_resources(resources)

View File

@ -1299,7 +1299,7 @@ class NotificationTest(APIv2TestBase):
class QuotaTest(APIv2TestBase): class QuotaTest(APIv2TestBase):
def test_create_network_quota(self): def test_create_network_quota(self):
cfg.CONF.set_override('quota_network', 1, group='QUOTAS') cfg.CONF.set_override('quota_network', 1, group='quotas')
initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}} initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}}
full_input = {'network': {'admin_state_up': True, 'subnets': []}} full_input = {'network': {'admin_state_up': True, 'subnets': []}}
full_input['network'].update(initial_input['network']) full_input['network'].update(initial_input['network'])
@ -1314,7 +1314,7 @@ class QuotaTest(APIv2TestBase):
res.json['QuantumError']) res.json['QuantumError'])
def test_create_network_quota_no_counts(self): def test_create_network_quota_no_counts(self):
cfg.CONF.set_override('quota_network', 1, group='QUOTAS') cfg.CONF.set_override('quota_network', 1, group='quotas')
initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}} initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}}
full_input = {'network': {'admin_state_up': True, 'subnets': []}} full_input = {'network': {'admin_state_up': True, 'subnets': []}}
full_input['network'].update(initial_input['network']) full_input['network'].update(initial_input['network'])
@ -1331,7 +1331,7 @@ class QuotaTest(APIv2TestBase):
res.json['QuantumError']) res.json['QuantumError'])
def test_create_network_quota_without_limit(self): def test_create_network_quota_without_limit(self):
cfg.CONF.set_override('quota_network', -1, group='QUOTAS') cfg.CONF.set_override('quota_network', -1, group='quotas')
initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}} initial_input = {'network': {'name': 'net1', 'tenant_id': _uuid()}}
instance = self.plugin.return_value instance = self.plugin.return_value
instance.get_networks_count.return_value = 3 instance.get_networks_count.return_value = 3

View File

@ -1949,7 +1949,7 @@ class TestNetworksV2(QuantumDbPluginV2TestCase):
if self._skip_native_bulk: if self._skip_native_bulk:
self.skipTest("Plugin does not support native bulk network create") self.skipTest("Plugin does not support native bulk network create")
quota = 4 quota = 4
cfg.CONF.set_override('quota_network', quota, group='QUOTAS') cfg.CONF.set_override('quota_network', quota, group='quotas')
res = self._create_network_bulk(self.fmt, quota + 1, 'test', True) res = self._create_network_bulk(self.fmt, quota + 1, 'test', True)
self._validate_behavior_on_bulk_failure(res, 'networks', errcode=409) self._validate_behavior_on_bulk_failure(res, 'networks', errcode=409)
@ -1957,7 +1957,7 @@ class TestNetworksV2(QuantumDbPluginV2TestCase):
if self._skip_native_bulk: if self._skip_native_bulk:
self.skipTest("Plugin does not support native bulk network create") self.skipTest("Plugin does not support native bulk network create")
quota = 2 quota = 2
cfg.CONF.set_override('quota_network', quota, group='QUOTAS') cfg.CONF.set_override('quota_network', quota, group='quotas')
networks = [{'network': {'name': 'n1', networks = [{'network': {'name': 'n1',
'tenant_id': self._tenant_id}}, 'tenant_id': self._tenant_id}},
{'network': {'name': 'n2', {'network': {'name': 'n2',
@ -1974,7 +1974,7 @@ class TestNetworksV2(QuantumDbPluginV2TestCase):
if self._skip_native_bulk: if self._skip_native_bulk:
self.skipTest("Plugin does not support native bulk network create") self.skipTest("Plugin does not support native bulk network create")
quota = 2 quota = 2
cfg.CONF.set_override('quota_network', quota, group='QUOTAS') cfg.CONF.set_override('quota_network', quota, group='quotas')
networks = [{'network': {'name': 'n1', networks = [{'network': {'name': 'n1',
'tenant_id': self._tenant_id}}, 'tenant_id': self._tenant_id}},
{'network': {'name': 'n2', {'network': {'name': 'n2',

View File

@ -48,7 +48,7 @@ class QuotaExtensionTestCase(testlib_api.WebTestCase):
cfg.CONF.set_override( cfg.CONF.set_override(
'quota_items', 'quota_items',
['network', 'subnet', 'port', 'extra1'], ['network', 'subnet', 'port', 'extra1'],
group='QUOTAS') group='quotas')
quota.QUOTAS = quota.QuotaEngine() quota.QUOTAS = quota.QuotaEngine()
quota.register_resources_from_config() quota.register_resources_from_config()
self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True) self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
@ -83,7 +83,7 @@ class QuotaExtensionDbTestCase(QuotaExtensionTestCase):
cfg.CONF.set_override( cfg.CONF.set_override(
'quota_driver', 'quota_driver',
'quantum.db.quota_db.DbQuotaDriver', 'quantum.db.quota_db.DbQuotaDriver',
group='QUOTAS') group='quotas')
super(QuotaExtensionDbTestCase, self).setUp() super(QuotaExtensionDbTestCase, self).setUp()
def test_quotas_loaded_right(self): def test_quotas_loaded_right(self):

View File

@ -169,7 +169,7 @@ class RouterServiceInsertionTestCase(base.BaseTestCase):
#just stubbing core plugin with LoadBalancer plugin #just stubbing core plugin with LoadBalancer plugin
cfg.CONF.set_override('core_plugin', plugin) cfg.CONF.set_override('core_plugin', plugin)
cfg.CONF.set_override('service_plugins', []) cfg.CONF.set_override('service_plugins', [])
cfg.CONF.set_override('quota_router', -1, group='QUOTAS') cfg.CONF.set_override('quota_router', -1, group='quotas')
self.addCleanup(cfg.CONF.reset) self.addCleanup(cfg.CONF.reset)
# Ensure 'stale' patched copies of the plugin are never returned # Ensure 'stale' patched copies of the plugin are never returned