Merge "Enable Quota DB driver by default"
This commit is contained in:
commit
8cca4bc8ee
@ -288,7 +288,7 @@ notification_driver = neutron.openstack.common.notifier.rpc_notifier
|
|||||||
# quota_security_group_rule = 100
|
# quota_security_group_rule = 100
|
||||||
|
|
||||||
# default driver to use for quota checks
|
# default driver to use for quota checks
|
||||||
# quota_driver = neutron.quota.ConfDriver
|
# quota_driver = neutron.db.quota_db.DbQuotaDriver
|
||||||
|
|
||||||
[agent]
|
[agent]
|
||||||
# Use "sudo neutron-rootwrap /etc/neutron/rootwrap.conf" to use the real
|
# Use "sudo neutron-rootwrap /etc/neutron/rootwrap.conf" to use the real
|
||||||
|
@ -47,7 +47,7 @@ quota_opts = [
|
|||||||
help=_('Number of ports allowed per tenant, minus for '
|
help=_('Number of ports allowed per tenant, minus for '
|
||||||
'unlimited')),
|
'unlimited')),
|
||||||
cfg.StrOpt('quota_driver',
|
cfg.StrOpt('quota_driver',
|
||||||
default='neutron.quota.ConfDriver',
|
default='neutron.db.quota_db.DbQuotaDriver',
|
||||||
help=_('Default driver to use for quota checks')),
|
help=_('Default driver to use for quota checks')),
|
||||||
]
|
]
|
||||||
# Register the configuration options
|
# Register the configuration options
|
||||||
@ -209,14 +209,18 @@ class QuotaEngine(object):
|
|||||||
def __init__(self, quota_driver_class=None):
|
def __init__(self, quota_driver_class=None):
|
||||||
"""Initialize a Quota object."""
|
"""Initialize a Quota object."""
|
||||||
|
|
||||||
if not quota_driver_class:
|
|
||||||
quota_driver_class = cfg.CONF.QUOTAS.quota_driver
|
|
||||||
|
|
||||||
if isinstance(quota_driver_class, basestring):
|
|
||||||
quota_driver_class = importutils.import_object(quota_driver_class)
|
|
||||||
|
|
||||||
self._resources = {}
|
self._resources = {}
|
||||||
self._driver = quota_driver_class
|
self._driver = None
|
||||||
|
self._driver_class = quota_driver_class
|
||||||
|
|
||||||
|
def get_driver(self):
|
||||||
|
if self._driver is None:
|
||||||
|
_driver_class = (self._driver_class or
|
||||||
|
cfg.CONF.QUOTAS.quota_driver)
|
||||||
|
if isinstance(_driver_class, basestring):
|
||||||
|
_driver_class = importutils.import_object(_driver_class)
|
||||||
|
self._driver = _driver_class
|
||||||
|
return self._driver
|
||||||
|
|
||||||
def __contains__(self, resource):
|
def __contains__(self, resource):
|
||||||
return resource in self._resources
|
return resource in self._resources
|
||||||
@ -281,8 +285,8 @@ class QuotaEngine(object):
|
|||||||
:param context: The request context, for access checks.
|
:param context: The request context, for access checks.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return self._driver.limit_check(context, tenant_id,
|
return self.get_driver().limit_check(context, tenant_id,
|
||||||
self._resources, values)
|
self._resources, values)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def resources(self):
|
def resources(self):
|
||||||
|
@ -32,6 +32,7 @@ from neutron.db import db_base_plugin_v2
|
|||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.plugins.nicira.dbexts import nicira_networkgw_db
|
from neutron.plugins.nicira.dbexts import nicira_networkgw_db
|
||||||
from neutron.plugins.nicira.extensions import nvp_networkgw as networkgw
|
from neutron.plugins.nicira.extensions import nvp_networkgw as networkgw
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit import test_api_v2
|
||||||
from neutron.tests.unit import test_db_plugin
|
from neutron.tests.unit import test_db_plugin
|
||||||
@ -93,6 +94,10 @@ class NetworkGatewayExtensionTestCase(base.BaseTestCase):
|
|||||||
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||||
self.api = webtest.TestApp(self.ext_mdw)
|
self.api = webtest.TestApp(self.ext_mdw)
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
def test_network_gateway_create(self):
|
def test_network_gateway_create(self):
|
||||||
nw_gw_id = _uuid()
|
nw_gw_id = _uuid()
|
||||||
data = {self._resource: {'name': 'nw-gw',
|
data = {self._resource: {'name': 'nw-gw',
|
||||||
|
@ -31,6 +31,7 @@ from neutron.extensions import vpnaas
|
|||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit import test_api_v2
|
||||||
from neutron.tests.unit import test_extensions
|
from neutron.tests.unit import test_extensions
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
@ -88,6 +89,10 @@ class VpnaasExtensionTestCase(testlib_api.WebTestCase):
|
|||||||
self.api = webtest.TestApp(self.ext_mdw)
|
self.api = webtest.TestApp(self.ext_mdw)
|
||||||
super(VpnaasExtensionTestCase, self).setUp()
|
super(VpnaasExtensionTestCase, self).setUp()
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self._plugin_patcher.stop()
|
self._plugin_patcher.stop()
|
||||||
self.api = None
|
self.api = None
|
||||||
|
@ -36,6 +36,7 @@ from neutron.manager import NeutronManager
|
|||||||
from neutron.openstack.common.notifier import api as notifer_api
|
from neutron.openstack.common.notifier import api as notifer_api
|
||||||
from neutron.openstack.common import policy as common_policy
|
from neutron.openstack.common import policy as common_policy
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
|
|
||||||
@ -118,6 +119,10 @@ class APIv2TestBase(base.BaseTestCase):
|
|||||||
api = router.APIRouter()
|
api = router.APIRouter()
|
||||||
self.api = webtest.TestApp(api)
|
self.api = webtest.TestApp(api)
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
|
|
||||||
class _ArgMatcher(object):
|
class _ArgMatcher(object):
|
||||||
"""An adapter to assist mock assertions, used to custom compare."""
|
"""An adapter to assist mock assertions, used to custom compare."""
|
||||||
@ -1377,6 +1382,10 @@ class ExtensionTestCase(base.BaseTestCase):
|
|||||||
api = router.APIRouter()
|
api = router.APIRouter()
|
||||||
self.api = webtest.TestApp(api)
|
self.api = webtest.TestApp(api)
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(ExtensionTestCase, self).tearDown()
|
super(ExtensionTestCase, self).tearDown()
|
||||||
self._plugin_patcher.stop()
|
self._plugin_patcher.stop()
|
||||||
|
@ -29,6 +29,7 @@ from neutron.common import config
|
|||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.plugins.common import constants
|
from neutron.plugins.common import constants
|
||||||
from neutron.plugins.openvswitch import ovs_neutron_plugin
|
from neutron.plugins.openvswitch import ovs_neutron_plugin
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
from neutron.tests.unit.extensions import extendedattribute as extattr
|
from neutron.tests.unit.extensions import extendedattribute as extattr
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit import test_api_v2
|
||||||
@ -108,6 +109,10 @@ class ExtensionExtendedAttributeTestCase(base.BaseTestCase):
|
|||||||
self.addCleanup(cfg.CONF.reset)
|
self.addCleanup(cfg.CONF.reset)
|
||||||
self.addCleanup(self.restore_attribute_map)
|
self.addCleanup(self.restore_attribute_map)
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
def restore_attribute_map(self):
|
def restore_attribute_map(self):
|
||||||
# Restore the original RESOURCE_ATTRIBUTE_MAP
|
# Restore the original RESOURCE_ATTRIBUTE_MAP
|
||||||
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map
|
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map
|
||||||
|
@ -30,6 +30,7 @@ from neutron import context
|
|||||||
from neutron.extensions import providernet as pnet
|
from neutron.extensions import providernet as pnet
|
||||||
from neutron.manager import NeutronManager
|
from neutron.manager import NeutronManager
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit import test_api_v2
|
||||||
from neutron.tests.unit import test_extensions
|
from neutron.tests.unit import test_extensions
|
||||||
from neutron.tests.unit import testlib_api
|
from neutron.tests.unit import testlib_api
|
||||||
@ -87,6 +88,10 @@ class ProvidernetExtensionTestCase(testlib_api.WebTestCase):
|
|||||||
self.addCleanup(self._restore_attribute_map)
|
self.addCleanup(self._restore_attribute_map)
|
||||||
self.api = webtest.TestApp(router.APIRouter())
|
self.api = webtest.TestApp(router.APIRouter())
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
def _restore_attribute_map(self):
|
def _restore_attribute_map(self):
|
||||||
# Restore the global RESOURCE_ATTRIBUTE_MAP
|
# Restore the global RESOURCE_ATTRIBUTE_MAP
|
||||||
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map
|
attributes.RESOURCE_ATTRIBUTE_MAP = self.saved_attr_map
|
||||||
|
@ -46,6 +46,7 @@ from neutron.openstack.common.notifier import api as notifier_api
|
|||||||
from neutron.openstack.common.notifier import test_notifier
|
from neutron.openstack.common.notifier import test_notifier
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
from neutron.plugins.common import constants as service_constants
|
from neutron.plugins.common import constants as service_constants
|
||||||
|
from neutron import quota
|
||||||
from neutron.tests.unit import test_api_v2
|
from neutron.tests.unit import test_api_v2
|
||||||
from neutron.tests.unit import test_db_plugin
|
from neutron.tests.unit import test_db_plugin
|
||||||
from neutron.tests.unit import test_extensions
|
from neutron.tests.unit import test_extensions
|
||||||
@ -114,6 +115,10 @@ class L3NatExtensionTestCase(testlib_api.WebTestCase):
|
|||||||
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||||
self.api = webtest.TestApp(self.ext_mdw)
|
self.api = webtest.TestApp(self.ext_mdw)
|
||||||
|
|
||||||
|
quota.QUOTAS._driver = None
|
||||||
|
cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self._plugin_patcher.stop()
|
self._plugin_patcher.stop()
|
||||||
self.api = None
|
self.api = None
|
||||||
|
@ -327,6 +327,13 @@ class QuotaExtensionDbTestCaseXML(QuotaExtensionDbTestCase):
|
|||||||
class QuotaExtensionCfgTestCase(QuotaExtensionTestCase):
|
class QuotaExtensionCfgTestCase(QuotaExtensionTestCase):
|
||||||
fmt = 'json'
|
fmt = 'json'
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
cfg.CONF.set_override(
|
||||||
|
'quota_driver',
|
||||||
|
'neutron.quota.ConfDriver',
|
||||||
|
group='QUOTAS')
|
||||||
|
super(QuotaExtensionCfgTestCase, self).setUp()
|
||||||
|
|
||||||
def test_quotas_default_values(self):
|
def test_quotas_default_values(self):
|
||||||
tenant_id = 'tenant_id1'
|
tenant_id = 'tenant_id1'
|
||||||
env = {'neutron.context': context.Context('', tenant_id)}
|
env = {'neutron.context': context.Context('', tenant_id)}
|
||||||
|
Loading…
Reference in New Issue
Block a user