elevate in proper places, fix a couple of typos
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user