Changes names of some quota values

Some variables which were actually per-tenant were
incorrectly named with a _user. Corrected this
confusion by making the old names deprecated
and providing new per-tenant names.

Closes Bug: #1232969

Change-Id: I541ed990c0cdd40b3805d2e2a166363d9ff2ad04
This commit is contained in:
Sonali Goyal 2015-10-05 18:17:20 +05:30 committed by amrith
parent 1cb7dc7792
commit e6620ff00f
10 changed files with 53 additions and 38 deletions

View File

@ -25,8 +25,8 @@
"trove_can_have_volume":true,
"trove_main_instance_has_volume": true,
"trove_max_accepted_volume_size": 25,
"trove_max_instances_per_user": 55,
"trove_max_volumes_per_user": 100,
"trove_max_instances_per_tenant": 55,
"trove_max_volumes_per_tenant": 100,
"use_reaper":false,
"root_removed_from_instance_api": true,
"root_timestamp_disabled": false,

View File

@ -104,10 +104,10 @@ block_device_mapping = vdb
device_path = /dev/vdb
# Maximum volume size for an instance
max_accepted_volume_size = 10
max_instances_per_user = 5
max_instances_per_tenant = 5
# Maximum volume capacity (in GB) spanning across all trove volumes per tenant
max_volumes_per_user = 100
max_backups_per_user = 5
max_volumes_per_tenant = 100
max_backups_per_tenant = 5
volume_time_out=30
# Config options for rate limits

View File

@ -71,9 +71,9 @@ nova_volume_service_type = volume
nova_volume_service_name = Volume Service
device_path = /dev/vdb
max_accepted_volume_size = 25
max_instances_per_user = 55
max_volumes_per_user = 100
max_backups_per_user = 5
max_instances_per_tenant = 55
max_volumes_per_tenant = 100
max_backups_per_tenant = 5
volume_time_out=30
# Config options for rate limits

View File

@ -164,15 +164,19 @@ common_opts = [
help='Maximum time (in seconds) to wait for a volume format.'),
cfg.StrOpt('mount_options', default='defaults,noatime',
help='Options to use when mounting a volume.'),
cfg.IntOpt('max_instances_per_user', default=5,
help='Default maximum number of instances per tenant.'),
cfg.IntOpt('max_instances_per_tenant',
default=5,
help='Default maximum number of instances per tenant.',
deprecated_name='max_instances_per_user'),
cfg.IntOpt('max_accepted_volume_size', default=5,
help='Default maximum volume size (in GB) for an instance.'),
cfg.IntOpt('max_volumes_per_user', default=20,
cfg.IntOpt('max_volumes_per_tenant', default=20,
help='Default maximum volume capacity (in GB) spanning across '
'all Trove volumes per tenant.'),
cfg.IntOpt('max_backups_per_user', default=50,
help='Default maximum number of backups created by a tenant.'),
'all Trove volumes per tenant.',
deprecated_name='max_volumes_per_user'),
cfg.IntOpt('max_backups_per_tenant', default=50,
help='Default maximum number of backups created by a tenant.',
deprecated_name='max_backups_per_user'),
cfg.StrOpt('quota_driver', default='trove.quota.quota.DbQuotaDriver',
help='Default driver to use for quota checks.'),
cfg.StrOpt('taskmanager_queue', default='taskmanager',

View File

@ -332,9 +332,11 @@ class QuotaEngine(object):
QUOTAS = QuotaEngine()
''' Define all kind of resources here '''
resources = [Resource(Resource.INSTANCES, 'max_instances_per_user'),
Resource(Resource.BACKUPS, 'max_backups_per_user'),
Resource(Resource.VOLUMES, 'max_volumes_per_user')]
resources = [Resource(Resource.INSTANCES,
'max_instances_per_tenant'),
Resource(Resource.BACKUPS, 'max_backups_per_tenant'),
Resource(Resource.VOLUMES, 'max_volumes_per_tenant')]
QUOTAS.register_resources(resources)

View File

@ -240,8 +240,8 @@ class CreateInstanceQuotaTest(unittest.TestCase):
self.test_info.dbaas_datastore = CONFIG.dbaas_datastore
def tearDown(self):
quota_dict = {'instances': CONFIG.trove_max_instances_per_user,
'volumes': CONFIG.trove_max_volumes_per_user}
quota_dict = {'instances': CONFIG.trove_max_instances_per_tenant,
'volumes': CONFIG.trove_max_volumes_per_tenant}
dbaas_admin.quota.update(self.test_info.user.tenant_id,
quota_dict)
@ -283,7 +283,7 @@ class CreateInstanceQuotaTest(unittest.TestCase):
self.test_info.volume = None
if VOLUME_SUPPORT:
assert_equal(CONFIG.trove_max_volumes_per_user,
assert_equal(CONFIG.trove_max_volumes_per_tenant,
verify_quota['volumes'])
self.test_info.volume = {'size':
CONFIG.get('trove_volume_size', 1)}

View File

@ -35,9 +35,10 @@ CONF = cfg.CONF
GROUP = "dbaas.api.limits"
DEFAULT_RATE = CONF.http_get_rate
DEFAULT_MAX_VOLUMES = CONF.max_volumes_per_user
DEFAULT_MAX_INSTANCES = CONF.max_instances_per_user
DEFAULT_MAX_BACKUPS = CONF.max_backups_per_user
DEFAULT_MAX_VOLUMES = CONF.max_volumes_per_tenant
DEFAULT_MAX_INSTANCES = CONF.max_instances_per_tenant
DEFAULT_MAX_BACKUPS = CONF.max_backups_per_tenant
def ensure_limits_are_not_faked(func):

View File

@ -42,8 +42,9 @@ class QuotasBase(object):
self.client2 = create_dbaas_client(self.user2)
self.mgmt_client = create_client(is_admin=True)
''' Orig quotas from config
"trove_max_instances_per_user": 55,
"trove_max_volumes_per_user": 100, '''
"trove_max_instances_per_tenant": 55,
"trove_max_volumes_per_tenant": 100, '''
self.original_quotas1 = self.mgmt_client.quota.show(self.user1.tenant)
self.original_quotas2 = self.mgmt_client.quota.show(self.user2.tenant)
@ -69,7 +70,8 @@ class DefaultQuotasTest(QuotasBase):
def check_quotas_are_set_to_defaults(self):
quotas = self.mgmt_client.quota.show(self.user1.tenant)
with Check() as check:
check.equal(CONFIG.trove_max_instances_per_user,
check.equal(CONFIG.trove_max_instances_per_tenant,
quotas["instances"])
check.equal(CONFIG.trove_max_volumes_per_user,
quotas["volumes"])
@ -103,7 +105,7 @@ class ChangeInstancesQuota(QuotasBase):
quotas = self.mgmt_client.quota.show(self.user1.tenant)
with Check() as check:
check.equal(0, quotas["instances"])
check.equal(CONFIG.trove_max_volumes_per_user,
check.equal(CONFIG.trove_max_volumes_per_tenant,
quotas["volumes"])
asserts.assert_equal(len(quotas), 2)
@ -154,7 +156,8 @@ class ChangeVolumesQuota(QuotasBase):
def verify_correct_update(self):
quotas = self.mgmt_client.quota.show(self.user1.tenant)
with Check() as check:
check.equal(CONFIG.trove_max_instances_per_user,
check.equal(CONFIG.trove_max_instances_per_tenant,
quotas["instances"])
check.equal(0, quotas["volumes"])
asserts.assert_equal(len(quotas), 2)

View File

@ -88,7 +88,8 @@ class TestConfig(object):
"report_directory": os.environ.get("REPORT_DIRECTORY", None),
"trove_volume_support": True,
"trove_volume_size": 1,
"trove_max_volumes_per_user": 100,
"trove_max_volumes_per_tenant": 100,
"trove_max_instances_per_tenant": 55,
"usage_endpoint": USAGE_ENDPOINT,
"root_on_create": False,
"mysql": {

View File

@ -33,8 +33,10 @@ Unit tests for the classes and functions in DbQuotaDriver.py.
CONF = cfg.CONF
resources = {
Resource.INSTANCES: Resource(Resource.INSTANCES, 'max_instances_per_user'),
Resource.VOLUMES: Resource(Resource.VOLUMES, 'max_volumes_per_user')
Resource.INSTANCES: Resource(Resource.INSTANCES,
'max_instances_per_tenant'),
Resource.VOLUMES: Resource(Resource.VOLUMES, 'max_volumes_per_tenant')
}
FAKE_TENANT1 = "123456"
@ -173,9 +175,10 @@ class DbQuotaDriverTest(trove_testtools.TestCase):
def test_get_defaults(self):
defaults = self.driver.get_defaults(resources)
self.assertEqual(CONF.max_instances_per_user,
self.assertEqual(CONF.max_instances_per_tenant,
defaults[Resource.INSTANCES])
self.assertEqual(CONF.max_volumes_per_user,
self.assertEqual(CONF.max_volumes_per_tenant,
defaults[Resource.VOLUMES])
def test_get_quota_by_tenant(self):
@ -202,7 +205,7 @@ class DbQuotaDriverTest(trove_testtools.TestCase):
self.assertEqual(FAKE_TENANT1, quota.tenant_id)
self.assertEqual(Resource.VOLUMES, quota.resource)
self.assertEqual(CONF.max_volumes_per_user, quota.hard_limit)
self.assertEqual(CONF.max_volumes_per_tenant, quota.hard_limit)
def test_get_all_quotas_by_tenant(self):
@ -236,11 +239,12 @@ class DbQuotaDriverTest(trove_testtools.TestCase):
self.assertEqual(FAKE_TENANT1, quotas[Resource.INSTANCES].tenant_id)
self.assertEqual(Resource.INSTANCES,
quotas[Resource.INSTANCES].resource)
self.assertEqual(CONF.max_instances_per_user,
self.assertEqual(CONF.max_instances_per_tenant,
quotas[Resource.INSTANCES].hard_limit)
self.assertEqual(FAKE_TENANT1, quotas[Resource.VOLUMES].tenant_id)
self.assertEqual(Resource.VOLUMES, quotas[Resource.VOLUMES].resource)
self.assertEqual(CONF.max_volumes_per_user,
self.assertEqual(CONF.max_volumes_per_tenant,
quotas[Resource.VOLUMES].hard_limit)
def test_get_all_quotas_by_tenant_with_one_default(self):
@ -260,7 +264,7 @@ class DbQuotaDriverTest(trove_testtools.TestCase):
self.assertEqual(22, quotas[Resource.INSTANCES].hard_limit)
self.assertEqual(FAKE_TENANT1, quotas[Resource.VOLUMES].tenant_id)
self.assertEqual(Resource.VOLUMES, quotas[Resource.VOLUMES].resource)
self.assertEqual(CONF.max_volumes_per_user,
self.assertEqual(CONF.max_volumes_per_tenant,
quotas[Resource.VOLUMES].hard_limit)
def test_get_quota_usage_by_tenant(self):
@ -434,7 +438,7 @@ class DbQuotaDriverTest(trove_testtools.TestCase):
self.mock_quota_result.all = Mock(return_value=[])
self.mock_usage_result.all = Mock(return_value=FAKE_QUOTAS)
delta = {'instances': 1, 'volumes': CONF.max_volumes_per_user + 1}
delta = {'instances': 1, 'volumes': CONF.max_volumes_per_tenant + 1}
self.assertRaises(exception.QuotaExceeded,
self.driver.reserve,
FAKE_TENANT1,