elevate in proper places, fix a couple of typos

This commit is contained in:
Vishvananda Ishaya
2010-10-13 22:05:21 -07:00
parent ca77625cff
commit cd916cb348
2 changed files with 9 additions and 5 deletions

View File

@@ -54,7 +54,8 @@ def get_quota(context, project_id):
def allowed_instances(context, num_instances, instance_type):
"""Check quota and return min(num_instances, allowed_instances)"""
project_id = context.project.id
project_id = context.project_id
context = context.elevated()
used_instances, used_cores = db.instance_data_get_for_project(context,
project_id)
quota = get_quota(context, project_id)
@@ -69,7 +70,8 @@ def allowed_instances(context, num_instances, instance_type):
def allowed_volumes(context, num_volumes, size):
"""Check quota and return min(num_volumes, allowed_volumes)"""
project_id = context.project.id
project_id = context.project_id
context = context.elevated()
used_volumes, used_gigabytes = db.volume_data_get_for_project(context,
project_id)
quota = get_quota(context, project_id)
@@ -84,7 +86,8 @@ def allowed_volumes(context, num_volumes, size):
def allowed_floating_ips(context, num_floating_ips):
"""Check quota and return min(num_floating_ips, allowed_floating_ips)"""
project_id = context.project.id
project_id = context.project_id
context = context.elevated()
used_floating_ips = db.floating_ip_count_by_project(context, project_id)
quota = get_quota(context, project_id)
allowed_floating_ips = quota['floating_ips'] - used_floating_ips

View File

@@ -54,10 +54,11 @@ class SchedulerManager(manager.Manager):
Falls back to schedule(context, topic) if method doesn't exist.
"""
driver_method = 'schedule_%s' % method
elevated = context.elevated()
try:
host = getattr(self.driver, driver_method)(context, *args, **kwargs)
host = getattr(self.driver, driver_method)(elevated, *args, **kwargs)
except AttributeError:
host = self.driver.schedule(context, topic, *args, **kwargs)
host = self.driver.schedule(elevated, topic, *args, **kwargs)
rpc.cast(context,
db.queue_get_for(context, topic, host),