quotas = {}
default_quotas = {}
- if CONF.use_default_quota_class:
+ if CONF.use_default_quota_class and not parent_project_id:
default_quotas = db.quota_class_get_default(context)
for resource in resources.values():
- if resource.name not in default_quotas:
- versionutils.report_deprecated_feature(LOG, _(
- "Default quota for resource: %(res)s is set "
- "by the default quota flag: quota_%(res)s, "
- "it is now deprecated. Please use the "
- "default quota class for default "
- "quota.") % {'res': resource.name})
+ if default_quotas:
+ if resource.name not in default_quotas:
+ versionutils.report_deprecated_feature(LOG, _(
+ "Default quota for resource: %(res)s is set "
+ "by the default quota flag: quota_%(res)s, "
+ "it is now deprecated. Please use the "
+ "default quota class for default "
+ "quota.") % {'res': resource.name})
quotas[resource.name] = default_quotas.get(resource.name,
(0 if parent_project_id
else resource.default))
def test_subproject_get_defaults(self):
# Test subproject default values.
- self._stub_quota_class_get_default_subproject()
self._stub_volume_type_get_all()
parent_project_id = 'test_parent_project_id'
result = self.driver.get_defaults(None,
)
self.stubs.Set(db, 'quota_class_get_default', fake_qcgd)
- def _stub_quota_class_get_default_subproject(self):
- # Stub out quota_class_get_default for subprojects
- def fake_qcgd(context):
- self.calls.append('quota_class_get_default')
- return {}
- self.stubs.Set(db, 'quota_class_get_default', fake_qcgd)
-
def _stub_volume_type_get_all(self):
def fake_vtga(context, inactive=False, filters=None):
return {}
self.stubs.Set(db, 'quota_usage_get_all_by_project', fake_qugabp)
self._stub_quota_class_get_all_by_name()
- self._stub_quota_class_get_default_subproject()
def test_get_project_quotas(self):
self._stub_get_by_project()
parent_project_id=parent_project_id)
self.assertEqual(self.calls, ['quota_get_all_by_project',
- 'quota_usage_get_all_by_project',
- 'quota_class_get_default', ])
+ 'quota_usage_get_all_by_project', ])
self.assertEqual(result, dict(volumes=dict(limit=10,
in_use=2,
reserved=0, ),