Help bring source code into compliance with the Cinder Style Commandments:
https://github.com/openstack/cinder/blob/master/HACKING.rst
This change covers all affected source in the cinder scheduler module, i.e.
cinder/scheduler/*.py and subdirectories.
Partially fixes: bug #
1190748
Change-Id: I75ad858ee62317bef6c59b9c0896f8a94a989d52
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):
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):
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
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
"""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)
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', {})
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):