Merge "Lower quota sizes always in preapproved list"

This commit is contained in:
Zuul 2018-02-12 03:27:02 +00:00 committed by Gerrit Code Review
commit 2cf6791eba
4 changed files with 51 additions and 5 deletions

View File

@ -459,7 +459,7 @@ class ProjectSetupActionTests(TestCase):
self.assertFalse('RegionThree' in nova_cache)
r2_cinderquota = cinder_cache['RegionThree'][
'test_project_id']['quota']
self.assertEqual(r2_cinderquota['gigabytes'], 50000)
self.assertEqual(r2_cinderquota['gigabytes'], 50001)
self.assertEqual(r2_cinderquota['snapshots'], 600)
self.assertEqual(r2_cinderquota['volumes'], 200)

View File

@ -1195,3 +1195,50 @@ class QuotaAPITests(APITestCase):
self.check_quota_cache('RegionOne', 'test_project_id', 'small')
self.check_quota_cache('RegionTwo', 'test_project_id', 'small')
def test_view_correct_sizes(self):
"""
Calculates the best 'fit' quota size from a custom quota.
"""
project = fake_clients.FakeProject(
name="test_project", id='test_project_id')
user = fake_clients.FakeUser(
name="test@example.com", password="123", email="test@example.com")
setup_identity_cache(projects=[project], users=[user])
admin_headers = {
'project_name': "test_project",
'project_id': project.id,
'roles': "project_admin,_member_,project_mod",
'username': "test@example.com",
'user_id': user.id,
'authenticated': True
}
url = "/v1/openstack/quotas/?regions=RegionOne"
response = self.client.get(url, headers=admin_headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.data['regions'][0]['current_quota_size'], 'small')
self.assertEqual(
response.data['regions'][0]['quota_change_options'], ['medium'])
cinder_cache['RegionOne'][project.id][
'quota'] = settings.PROJECT_QUOTA_SIZES['large']['cinder']
nova_cache['RegionOne'][project.id][
'quota'] = settings.PROJECT_QUOTA_SIZES['large']['nova']
neutron_cache['RegionOne'][project.id][
'quota'] = settings.PROJECT_QUOTA_SIZES['large']['neutron']
response = self.client.get(url, headers=admin_headers)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.data['regions'][0]['current_quota_size'], 'large')
self.assertEqual(
response.data['regions'][0]['quota_change_options'],
['small', 'medium'])

View File

@ -207,9 +207,8 @@ class QuotaManager(object):
except ValueError:
return []
quota_change_list = []
if list_position - 1 >= 0:
quota_change_list.append(quota_list[list_position - 1])
quota_change_list = quota_list[:list_position]
if list_position + 1 < len(quota_list):
quota_change_list.append(quota_list[list_position + 1])

View File

@ -374,7 +374,7 @@ PROJECT_QUOTA_SIZES = {
},
"large_cinder_only": {
"cinder": {
"gigabytes": 50000,
"gigabytes": 50001,
"volumes": 200,
"snapshots": 600
},