Ensure our quotas/limits are consistent with other OpenStack projects

Change-Id: Ib09a4339109765a7703020ebceed6acad60dc095
This commit is contained in:
Kiall Mac Innes 2013-05-15 16:50:54 +01:00
parent db57bc531c
commit 59e432e1c1
7 changed files with 27 additions and 19 deletions

View File

@ -37,6 +37,9 @@ def get_limits():
return flask.jsonify(limits_schema.filter({
"limits": {
"absolute": absolute_limits
"absolute": {
"maxDomains": absolute_limits['domains'],
"maxDomainRecords": absolute_limits['domain_records']
}
}
}))

View File

@ -587,7 +587,7 @@ class Service(rpc_service.Service):
quota_criterion = {'domain_id': domain_id}
record_count = self.count_records(context, criterion=quota_criterion)
self.quota.limit_check(context, domain['tenant_id'],
records=record_count)
domain_records=record_count)
# Ensure the record name is valid
self._is_valid_record_name(context, domain, values['name'],

View File

@ -22,8 +22,8 @@ LOG = logging.getLogger(__name__)
cfg.CONF.register_opts([
cfg.IntOpt('quota-domains', default=10, help='Number of domains allowed '
'per tenant'),
cfg.StrOpt('quota-records', default=500, help='Number of records allowed '
'per domain'),
cfg.StrOpt('quota-domain-records', default=500, help='Number of records '
'allowed per domain'),
])

View File

@ -34,7 +34,7 @@ class Quota(Plugin):
"""
quotas = {
'domains': cfg.CONF.quota_domains,
'records': cfg.CONF.quota_records,
'domain_records': cfg.CONF.quota_domain_records,
}
quotas.update(self._get_tenant_quotas(context, tenant_id))

View File

@ -15,10 +15,10 @@
"absolute": {
"type": "object",
"properties": {
"domains": {
"maxDomains": {
"type": "integer"
},
"records": {
"maxDomainRecords": {
"type": "integer"
}
}

View File

@ -720,7 +720,7 @@ class CentralServiceTest(CentralTestCase):
self.assertEqual(record['data'], values['data'])
def test_create_record_over_quota(self):
self.config(quota_records=1)
self.config(quota_domain_records=1)
domain = self.create_domain()

View File

@ -37,7 +37,7 @@ class QuotaTestCase(TestCase):
self.assertIsNotNone(quotas)
self.assertEqual(quotas, {
'domains': cfg.CONF.quota_domains,
'records': cfg.CONF.quota_records
'domain_records': cfg.CONF.quota_domain_records
})
def test_limit_check_unknown(self):
@ -53,13 +53,16 @@ class QuotaTestCase(TestCase):
context = self.get_admin_context()
self.quota.limit_check(context, 'tenant_id', domains=0)
self.quota.limit_check(context, 'tenant_id', records=0)
self.quota.limit_check(context, 'tenant_id', domains=0, records=0)
self.quota.limit_check(context, 'tenant_id', domain_records=0)
self.quota.limit_check(context, 'tenant_id', domains=0,
domain_records=0)
self.quota.limit_check(context, 'tenant_id',
domains=(cfg.CONF.quota_domains - 1))
self.quota.limit_check(context, 'tenant_id',
records=(cfg.CONF.quota_records - 1))
self.quota.limit_check(
context,
'tenant_id',
domain_records=(cfg.CONF.quota_domain_records - 1))
def test_limit_check_at(self):
context = self.get_admin_context()
@ -69,8 +72,10 @@ class QuotaTestCase(TestCase):
domains=cfg.CONF.quota_domains)
with self.assertRaises(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id',
records=cfg.CONF.quota_records)
self.quota.limit_check(
context,
'tenant_id',
domain_records=cfg.CONF.quota_domain_records)
def test_limit_check_over(self):
context = self.get_admin_context()
@ -79,16 +84,16 @@ class QuotaTestCase(TestCase):
self.quota.limit_check(context, 'tenant_id', domains=99999)
with self.assertRaises(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', records=99999)
self.quota.limit_check(context, 'tenant_id', domain_records=99999)
with self.assertRaises(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=99999,
records=99999)
domain_records=99999)
with self.assertRaises(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=99999,
records=0)
domain_records=0)
with self.assertRaises(exceptions.OverQuota):
self.quota.limit_check(context, 'tenant_id', domains=0,
records=99999)
domain_records=99999)