From 59e432e1c1623039ced9fe57c81c58eb10b27654 Mon Sep 17 00:00:00 2001 From: Kiall Mac Innes Date: Wed, 15 May 2013 16:50:54 +0100 Subject: [PATCH] Ensure our quotas/limits are consistent with other OpenStack projects Change-Id: Ib09a4339109765a7703020ebceed6acad60dc095 --- moniker/api/v1/limits.py | 5 +++- moniker/central/service.py | 2 +- moniker/quota/__init__.py | 4 ++-- moniker/quota/base.py | 2 +- moniker/resources/schemas/v1/limits.json | 4 ++-- moniker/tests/test_central/test_service.py | 2 +- moniker/tests/test_quota/__init__.py | 27 +++++++++++++--------- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/moniker/api/v1/limits.py b/moniker/api/v1/limits.py index 363b9d5f0..652696f3d 100644 --- a/moniker/api/v1/limits.py +++ b/moniker/api/v1/limits.py @@ -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'] + } } })) diff --git a/moniker/central/service.py b/moniker/central/service.py index 3583c657f..aa0db80b5 100644 --- a/moniker/central/service.py +++ b/moniker/central/service.py @@ -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'], diff --git a/moniker/quota/__init__.py b/moniker/quota/__init__.py index 18a7011f0..ddda7c99c 100644 --- a/moniker/quota/__init__.py +++ b/moniker/quota/__init__.py @@ -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'), ]) diff --git a/moniker/quota/base.py b/moniker/quota/base.py index 99eb06789..2758050e6 100644 --- a/moniker/quota/base.py +++ b/moniker/quota/base.py @@ -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)) diff --git a/moniker/resources/schemas/v1/limits.json b/moniker/resources/schemas/v1/limits.json index 7bef4ccfc..3dcb9006d 100644 --- a/moniker/resources/schemas/v1/limits.json +++ b/moniker/resources/schemas/v1/limits.json @@ -15,10 +15,10 @@ "absolute": { "type": "object", "properties": { - "domains": { + "maxDomains": { "type": "integer" }, - "records": { + "maxDomainRecords": { "type": "integer" } } diff --git a/moniker/tests/test_central/test_service.py b/moniker/tests/test_central/test_service.py index 1417b6240..e2ece4585 100644 --- a/moniker/tests/test_central/test_service.py +++ b/moniker/tests/test_central/test_service.py @@ -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() diff --git a/moniker/tests/test_quota/__init__.py b/moniker/tests/test_quota/__init__.py index acfe1dcd0..7656eb0d5 100644 --- a/moniker/tests/test_quota/__init__.py +++ b/moniker/tests/test_quota/__init__.py @@ -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)