Merge "cinder.schedule: Replace 'locals()' with explicit values"
This commit is contained in:
@@ -126,7 +126,11 @@ class FilterScheduler(driver.Scheduler):
|
||||
|
||||
last_host = hosts[-1]
|
||||
msg = _("Error scheduling %(volume_id)s from last vol-service: "
|
||||
"%(last_host)s : %(exc)s") % locals()
|
||||
"%(last_host)s : %(exc)s") % {
|
||||
'volume_id': volume_id,
|
||||
'last_host': last_host,
|
||||
'exc': exc,
|
||||
}
|
||||
LOG.error(msg)
|
||||
|
||||
def _populate_retry(self, filter_properties, properties):
|
||||
@@ -155,7 +159,10 @@ class FilterScheduler(driver.Scheduler):
|
||||
|
||||
if retry['num_attempts'] > max_attempts:
|
||||
msg = _("Exceeded max scheduling attempts %(max_attempts)d for "
|
||||
"volume %(volume_id)s") % locals()
|
||||
"volume %(volume_id)s") % {
|
||||
'max_attempts': max_attempts,
|
||||
'volume_id': volume_id,
|
||||
}
|
||||
raise exception.NoValidHost(reason=msg)
|
||||
|
||||
def _schedule(self, context, request_spec, filter_properties=None):
|
||||
@@ -202,12 +209,12 @@ class FilterScheduler(driver.Scheduler):
|
||||
if not hosts:
|
||||
return None
|
||||
|
||||
LOG.debug(_("Filtered %(hosts)s") % locals())
|
||||
LOG.debug(_("Filtered %s") % hosts)
|
||||
# weighted_host = WeightedHost() ... the best
|
||||
# host for the job.
|
||||
weighed_hosts = self.host_manager.get_weighed_hosts(hosts,
|
||||
filter_properties)
|
||||
best_host = weighed_hosts[0]
|
||||
LOG.debug(_("Choosing %(best_host)s") % locals())
|
||||
LOG.debug(_("Choosing %s") % best_host)
|
||||
best_host.obj.consume_from_volume(volume_properties)
|
||||
return best_host
|
||||
|
||||
@@ -39,7 +39,8 @@ 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
|
||||
|
||||
@@ -238,11 +238,13 @@ class HostManager(object):
|
||||
"""Update the per-service capabilities based on this notification."""
|
||||
if service_name != 'volume':
|
||||
LOG.debug(_('Ignoring %(service_name)s service update '
|
||||
'from %(host)s'), locals())
|
||||
'from %(host)s'),
|
||||
{'service_name': service_name, 'host': host})
|
||||
return
|
||||
|
||||
LOG.debug(_("Received %(service_name)s service update from "
|
||||
"%(host)s.") % locals())
|
||||
"%(host)s.") %
|
||||
{'service_name': service_name, 'host': host})
|
||||
|
||||
# Copy the capabilities, so we don't modify the original dict
|
||||
capab_copy = dict(capabilities)
|
||||
|
||||
@@ -116,7 +116,8 @@ class SchedulerManager(manager.Manager):
|
||||
|
||||
def _set_volume_state_and_notify(self, method, updates, context, ex,
|
||||
request_spec):
|
||||
LOG.error(_("Failed to schedule_%(method)s: %(ex)s") % locals())
|
||||
LOG.error(_("Failed to schedule_%(method)s: %(ex)s") %
|
||||
{'method': method, 'ex': ex})
|
||||
|
||||
volume_state = updates['volume_state']
|
||||
properties = request_spec.get('volume_properties', {})
|
||||
|
||||
@@ -68,16 +68,16 @@ class SchedulerOptions(object):
|
||||
return os.path.getmtime(filename)
|
||||
except os.error as e:
|
||||
LOG.exception(_("Could not stat scheduler options file "
|
||||
"%(filename)s: '%(e)s'"), locals())
|
||||
"%(filename)s: '%(e)s'"),
|
||||
{'filename': filename, 'e': e})
|
||||
raise
|
||||
|
||||
def _load_file(self, handle):
|
||||
"""Decode the JSON file. Broken out for testing."""
|
||||
try:
|
||||
return json.load(handle)
|
||||
except ValueError as e:
|
||||
LOG.exception(_("Could not decode scheduler options: "
|
||||
"'%(e)s'") % locals())
|
||||
except ValueError, e:
|
||||
LOG.exception(_("Could not decode scheduler options: '%s'") % e)
|
||||
return {}
|
||||
|
||||
def _get_time_now(self):
|
||||
|
||||
Reference in New Issue
Block a user