Remove locals() from scheduler filters

Just removed locals() and replaced it with an explicit dicionary.

Change-Id: Id476a684abde36238b5abfe8ce4c3ddb0874423b
This commit is contained in:
Belmiro Moreira
2013-05-22 22:11:53 +02:00
parent 83d3fc3183
commit cf6bececf4
9 changed files with 27 additions and 14 deletions

View File

@@ -47,13 +47,13 @@ class AggregateInstanceExtraSpecsFilter(filters.BaseHostFilter):
aggregate_vals = metadata.get(key, None)
if not aggregate_vals:
LOG.debug(_("%(host_state)s fails instance_type extra_specs "
"requirements"), locals())
"requirements"), {'host_state': host_state})
return False
for aggregate_val in aggregate_vals:
if extra_specs_ops.match(aggregate_val, req):
break
else:
LOG.debug(_("%(host_state)s fails instance_type extra_specs "
"requirements"), locals())
"requirements"), {'host_state': host_state})
return False
return True

View File

@@ -55,6 +55,6 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter):
if not self._satisfies_extra_specs(host_state.capabilities,
instance_type):
LOG.debug(_("%(host_state)s fails instance_type extra_specs "
"requirements"), locals())
"requirements"), {'host_state': host_state})
return False
return True

View File

@@ -38,10 +38,10 @@ class ComputeFilter(filters.BaseHostFilter):
alive = self.servicegroup_api.service_is_up(service)
if not alive or service['disabled']:
LOG.debug(_("%(host_state)s is disabled or has not been "
"heard from in a while"), locals())
"heard from in a while"), {'host_state': host_state})
return False
if not capabilities.get("enabled", True):
LOG.debug(_("%(host_state)s is disabled via capabilities"),
locals())
{'host_state': host_state})
return False
return True

View File

@@ -46,7 +46,9 @@ class DiskFilter(filters.BaseHostFilter):
if not usable_disk_mb >= requested_disk:
LOG.debug(_("%(host_state)s does not have %(requested_disk)s MB "
"usable disk, it only has %(usable_disk_mb)s MB usable "
"disk."), locals())
"disk."), {'host_state': host_state,
'requested_disk': requested_disk,
'usable_disk_mb': usable_disk_mb})
return False
disk_gb_limit = disk_mb_limit / 1024

View File

@@ -47,7 +47,7 @@ class ImagePropertiesFilter(filters.BaseHostFilter):
if not supp_instances:
LOG.debug(_("Instance contains properties %(image_props)s, "
"but no corresponding capabilities are advertised "
"by the compute node"), locals())
"by the compute node"), {'image_props': image_props})
return False
def _compare_props(props, other_props):
@@ -60,12 +60,16 @@ class ImagePropertiesFilter(filters.BaseHostFilter):
if _compare_props(checked_img_props, supp_inst):
LOG.debug(_("Instance properties %(image_props)s "
"are satisfied by compute host capabilities "
"%(capabilities)s"), locals())
"%(capabilities)s"),
{'image_props': image_props,
'capabilities': capabilities})
return True
LOG.debug(_("Instance contains properties %(image_props)s "
"that are not provided by the compute node "
"capabilities %(capabilities)s"), locals())
"capabilities %(capabilities)s"),
{'image_props': image_props,
'capabilities': capabilities})
return False
def host_passes(self, host_state, filter_properties):
@@ -80,6 +84,6 @@ class ImagePropertiesFilter(filters.BaseHostFilter):
if not self._instance_supported(capabilities, image_props):
LOG.debug(_("%(host_state)s does not support requested "
"instance_properties"), locals())
"instance_properties"), {'host_state': host_state})
return False
return True

View File

@@ -40,5 +40,7 @@ class IoOpsFilter(filters.BaseHostFilter):
passes = num_io_ops < max_io_ops
if not passes:
LOG.debug(_("%(host_state)s fails I/O ops check: Max IOs per host "
"is set to %(max_io_ops)s"), locals())
"is set to %(max_io_ops)s"),
{'host_state': host_state,
'max_io_ops': max_io_ops})
return passes

View File

@@ -38,5 +38,6 @@ class NumInstancesFilter(filters.BaseHostFilter):
if not passes:
LOG.debug(_("%(host_state)s fails num_instances check: Max "
"instances per host is set to %(max_instances)s"),
locals())
{'host_state': host_state,
'max_instances': max_instances})
return passes

View File

@@ -45,7 +45,9 @@ class RamFilter(filters.BaseHostFilter):
if not usable_ram >= requested_ram:
LOG.debug(_("%(host_state)s does not have %(requested_ram)s MB "
"usable ram, it only has %(usable_ram)s MB usable ram."),
locals())
{'host_state': host_state,
'requested_ram': requested_ram,
'usable_ram': usable_ram})
return False
# save oversubscription limit for compute node to test against:

View File

@@ -39,7 +39,9 @@ class RetryFilter(filters.BaseHostFilter):
pass_msg = "passes" if passes else "fails"
LOG.debug(_("Host %(host)s %(pass_msg)s. Previously tried hosts: "
"%(hosts)s") % locals())
"%(hosts)s") % {'host': host,
'pass_msg': pass_msg,
'hosts': hosts})
# Host passes if it's not in the list of previously attempted hosts:
return passes