2020-12-31 02:25:19 |
haixin |
description |
When we need to update volume type name, will call:
QUOTAS.update_quota_resource(elevated, old_type_name,name)
in this function the code below:
def update_quota_resource(self, context, old_type_name, new_type_name):
for quota in ('volumes', 'gigabytes', 'snapshots'):
old_res = "%s_%s" % (quota, old_type_name)
new_res = "%s_%s" % (quota, new_type_name)
db.quota_usage_update_resource(context,
old_res,
new_res)
db.quota_class_update_resource(context, # it is not necessary
old_res,
new_res)
db.quota_update_resource(context, # it is not necessary
old_res,
new_res)
As everyone knows, there is no such resource named as "%s_%s" % (quota_type, volulme_type_name) in database table of quota_classes or quotas.
in table quota_classes, there are only quota default value.
in table quotas, there are only five resources for each project, there are gigabytes, volumes, backups,backup_gigabytes, snapshots. they are value of project quota.
on the other hand, in fuction : def reservation_commit(context, reservations, project_id=None):
this is the only way to update quota usage, usages will get from table quota_usages.
So resource named as "%s_%s" % (quota_type, volulme_type_name) only exist in table quota_usages,
and we not need to call quota_class_update_resource and quota_update_resource when update volume type name. |
When we need to update volume type name, will call:
QUOTAS.update_quota_resource(elevated, old_type_name,name)
in this function the code below:
def update_quota_resource(self, context, old_type_name, new_type_name):
for quota in ('volumes', 'gigabytes', 'snapshots'):
old_res = "%s_%s" % (quota, old_type_name)
new_res = "%s_%s" % (quota, new_type_name)
db.quota_usage_update_resource(context,
old_res,
new_res)
db.quota_class_update_resource(context, # it is not necessary
old_res,
new_res)
db.quota_update_resource(context,
old_res,
new_res)
As everyone knows, there is no such resource named as "%s_%s" % (quota_type, volulme_type_name) in database table of quota_classes.
in table quota_classes, there are only quota default value for new project.
Unless we manually set the default quota for volume type. These values are default values, and we don't know how the user will name the volume type before we create it,So it doesn't make sense to preset a default value for a volume type in advance.
so resource named as "%s_%s" % (quota_type, volulme_type_name) only exist in table quota_usages or quotas if we set quota for specified volume type.
will not appear in table of quota_classes.
so we not need to call quota_class_update_resource when update volume type name. |
|