diff options
author | Rick Harris <rick.harris@rackspace.com> | 2011-02-25 01:31:02 +0000 |
---|---|---|
committer | Rick Harris <rick.harris@rackspace.com> | 2011-02-25 01:31:02 +0000 |
commit | c8345c9ebc0357f1fe06ac520f286f036cb0596c (patch) | |
tree | 197e6c852db619cf03800a77585637d8671d3d71 /nova/quota.py | |
parent | 05d135be0c0d8a90a97d62005a101345964800cf (diff) | |
parent | c8b630a78e955756e77be8879c1da863a5357ea0 (diff) | |
download | nova-c8345c9ebc0357f1fe06ac520f286f036cb0596c.tar.gz nova-c8345c9ebc0357f1fe06ac520f286f036cb0596c.tar.xz nova-c8345c9ebc0357f1fe06ac520f286f036cb0596c.zip |
Merging trunk, small fixes
Diffstat (limited to 'nova/quota.py')
-rw-r--r-- | nova/quota.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/nova/quota.py b/nova/quota.py index 3884eb308..6b52a97fa 100644 --- a/nova/quota.py +++ b/nova/quota.py @@ -35,6 +35,8 @@ flags.DEFINE_integer('quota_gigabytes', 1000, 'number of volume gigabytes allowed per project') flags.DEFINE_integer('quota_floating_ips', 10, 'number of floating ips allowed per project') +flags.DEFINE_integer('quota_metadata_items', 128, + 'number of metadata items allowed per instance') def get_quota(context, project_id): @@ -42,7 +44,8 @@ def get_quota(context, project_id): 'cores': FLAGS.quota_cores, 'volumes': FLAGS.quota_volumes, 'gigabytes': FLAGS.quota_gigabytes, - 'floating_ips': FLAGS.quota_floating_ips} + 'floating_ips': FLAGS.quota_floating_ips, + 'metadata_items': FLAGS.quota_metadata_items} try: quota = db.quota_get(context, project_id) for key in rval.keys(): @@ -94,6 +97,15 @@ def allowed_floating_ips(context, num_floating_ips): return min(num_floating_ips, allowed_floating_ips) +def allowed_metadata_items(context, num_metadata_items): + """Check quota; return min(num_metadata_items,allowed_metadata_items)""" + project_id = context.project_id + context = context.elevated() + quota = get_quota(context, project_id) + num_allowed_metadata_items = quota['metadata_items'] + return min(num_metadata_items, num_allowed_metadata_items) + + class QuotaError(exception.ApiError): """Quota Exceeeded""" pass |