quota: remove unused Quota driver methods

The BaseResource.quota() method was the only method calling the
QuotaDriver.get_by_project(), get_by_project_and_user() and
get_by_class() methods. The BaseResource.quota() method was only being
called from unit tests. The last patch in this series removed that
method and now the QuotaDriver.get_by_project(),
get_by_project_and_user() and get_by_class() methods can now be removed
since they have no callers other than unit tests.

Change-Id: Iec72af79867c1d992ad109a0d0528431c61f22b4
This commit is contained in:
Jay Pipes 2018-10-24 09:47:57 -04:00
parent bcb0bc7fe9
commit 1aa758e522
2 changed files with 0 additions and 120 deletions

View File

@ -41,22 +41,6 @@ class DbQuotaDriver(object):
"""
UNLIMITED_VALUE = -1
def get_by_project_and_user(self, context, project_id, user_id, resource):
"""Get a specific quota by project and user."""
return objects.Quotas.get(context, project_id, resource,
user_id=user_id)
def get_by_project(self, context, project_id, resource):
"""Get a specific quota by project."""
return objects.Quotas.get(context, project_id, resource)
def get_by_class(self, context, quota_class, resource):
"""Get a specific quota by quota class."""
return objects.Quotas.get_class(context, quota_class, resource)
def get_defaults(self, context, resources):
"""Given a list of resources, retrieve the default quotas.
Use the class quotas named `_DEFAULT_QUOTA_NAME` as default quotas,
@ -657,21 +641,6 @@ class NoopQuotaDriver(object):
should not.
"""
def get_by_project_and_user(self, context, project_id, user_id, resource):
"""Get a specific quota by project and user."""
# Unlimited
return -1
def get_by_project(self, context, project_id, resource):
"""Get a specific quota by project."""
# Unlimited
return -1
def get_by_class(self, context, quota_class, resource):
"""Get a specific quota by quota class."""
# Unlimited
return -1
def get_defaults(self, context, resources):
"""Given a list of resources, retrieve the default quotas.
@ -973,22 +942,6 @@ class QuotaEngine(object):
for resource in resources:
self.register_resource(resource)
def get_by_project_and_user(self, context, project_id, user_id, resource):
"""Get a specific quota by project and user."""
return self._driver.get_by_project_and_user(context, project_id,
user_id, resource)
def get_by_project(self, context, project_id, resource):
"""Get a specific quota by project."""
return self._driver.get_by_project(context, project_id, resource)
def get_by_class(self, context, quota_class, resource):
"""Get a specific quota by quota class."""
return self._driver.get_by_class(context, quota_class, resource)
def get_defaults(self, context):
"""Retrieve the default quotas.

View File

@ -281,29 +281,6 @@ class FakeDriver(object):
self.by_class = by_class or {}
self.reservations = reservations or []
def get_by_project_and_user(self, context, project_id, user_id, resource):
self.called.append(('get_by_project_and_user',
context, project_id, user_id, resource))
try:
return self.by_user[user_id][resource]
except KeyError:
raise exception.ProjectUserQuotaNotFound(project_id=project_id,
user_id=user_id)
def get_by_project(self, context, project_id, resource):
self.called.append(('get_by_project', context, project_id, resource))
try:
return self.by_project[project_id][resource]
except KeyError:
raise exception.ProjectQuotaNotFound(project_id=project_id)
def get_by_class(self, context, quota_class, resource):
self.called.append(('get_by_class', context, quota_class, resource))
try:
return self.by_class[quota_class][resource]
except KeyError:
raise exception.QuotaClassNotFound(class_name=quota_class)
def get_defaults(self, context, resources):
self.called.append(('get_defaults', context, resources))
return resources
@ -446,45 +423,6 @@ class QuotaEngineTestCase(test.TestCase):
test_resource3=resources[2],
))
def test_get_by_project_and_user(self):
context = FakeContext('test_project', 'test_class')
driver = FakeDriver(by_user=dict(
fake_user=dict(test_resource=42)))
quota_obj = quota.QuotaEngine(quota_driver=driver)
result = quota_obj.get_by_project_and_user(context, 'test_project',
'fake_user', 'test_resource')
self.assertEqual(driver.called, [
('get_by_project_and_user', context, 'test_project',
'fake_user', 'test_resource'),
])
self.assertEqual(result, 42)
def test_get_by_project(self):
context = FakeContext('test_project', 'test_class')
driver = FakeDriver(by_project=dict(
test_project=dict(test_resource=42)))
quota_obj = quota.QuotaEngine(quota_driver=driver)
result = quota_obj.get_by_project(context, 'test_project',
'test_resource')
self.assertEqual(driver.called, [
('get_by_project', context, 'test_project', 'test_resource'),
])
self.assertEqual(result, 42)
def test_get_by_class(self):
context = FakeContext('test_project', 'test_class')
driver = FakeDriver(by_class=dict(
test_class=dict(test_resource=42)))
quota_obj = quota.QuotaEngine(quota_driver=driver)
result = quota_obj.get_by_class(context, 'test_class', 'test_resource')
self.assertEqual(driver.called, [
('get_by_class', context, 'test_class', 'test_resource'),
])
self.assertEqual(result, 42)
def _make_quota_obj(self, driver):
quota_obj = quota.QuotaEngine(quota_driver=driver)
resources = [
@ -966,17 +904,6 @@ class DbQuotaDriverTestCase(test.TestCase):
)
self.stub_out('nova.db.api.quota_get', fake_quota_get)
def test_get_by_project_and_user(self):
self._stub_get_by_project_and_user_specific()
result = self.driver.get_by_project_and_user(
FakeContext('test_project', 'test_class'),
'test_project', 'fake_user', 'test_resource')
self.assertEqual(self.calls, ['quota_get'])
self.assertEqual(result, dict(
test_resource=dict(in_use=20),
))
def _stub_get_by_project(self):
def fake_qgabp(context, project_id):
self.calls.append('quota_get_all_by_project')