~0x44/nova/bug838466

« back to all changes in this revision

Viewing changes to nova/quota.py

  • Committer: Cerberus
  • Date: 2011-02-28 17:39:23 UTC
  • mfrom: (749 nova)
  • mto: This revision was merged to the branch mainline in revision 762.
  • Revision ID: matt.dietz@rackspace.com-20110228173923-1e3upi2ddoc2j4xl
Merge from trunk and merge conflict resolution

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
                     'number of volume gigabytes allowed per project')
36
36
flags.DEFINE_integer('quota_floating_ips', 10,
37
37
                     'number of floating ips allowed per project')
 
38
flags.DEFINE_integer('quota_metadata_items', 128,
 
39
                     'number of metadata items allowed per instance')
38
40
 
39
41
 
40
42
def get_quota(context, project_id):
42
44
            'cores': FLAGS.quota_cores,
43
45
            'volumes': FLAGS.quota_volumes,
44
46
            'gigabytes': FLAGS.quota_gigabytes,
45
 
            'floating_ips': FLAGS.quota_floating_ips}
 
47
            'floating_ips': FLAGS.quota_floating_ips,
 
48
            'metadata_items': FLAGS.quota_metadata_items}
46
49
    try:
47
50
        quota = db.quota_get(context, project_id)
48
51
        for key in rval.keys():
94
97
    return min(num_floating_ips, allowed_floating_ips)
95
98
 
96
99
 
 
100
def allowed_metadata_items(context, num_metadata_items):
 
101
    """Check quota; return min(num_metadata_items,allowed_metadata_items)"""
 
102
    project_id = context.project_id
 
103
    context = context.elevated()
 
104
    quota = get_quota(context, project_id)
 
105
    num_allowed_metadata_items = quota['metadata_items']
 
106
    return min(num_metadata_items, num_allowed_metadata_items)
 
107
 
 
108
 
97
109
class QuotaError(exception.ApiError):
98
110
    """Quota Exceeeded"""
99
111
    pass