User quota update should not exceed project quota

Move the default user quota setting code from db to quota.py,
because it is necessary to check if user quota is set in db
to get the settable quota for the user under a project.

Fixes bug 1208400

Change-Id: I83a4a7fcd8bf80b20e4e700bad7dd31294f8ed0b
This commit is contained in:
liyingjun
2013-08-05 17:57:15 +08:00
parent f1a5a4792a
commit 9c3de372dd

View File

@@ -222,6 +222,11 @@ class DbQuotaDriver(object):
"""
user_quotas = db.quota_get_all_by_project_and_user(context,
project_id, user_id)
# Use the project quota for default user quota.
proj_quotas = db.quota_get_all_by_project(context, project_id)
for key, value in proj_quotas.iteritems():
if key not in user_quotas.keys():
user_quotas[key] = value
user_usages = None
if usages:
user_usages = db.quota_usage_get_all_by_project_and_user(context,