]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
cinder.schedule: Replace 'locals()' with explicit values
authorAndrew Forrest <forrest@research.att.com>
Sat, 15 Jun 2013 18:45:15 +0000 (11:45 -0700)
committerAndrew Forrest <forrest@research.att.com>
Sun, 16 Jun 2013 15:09:34 +0000 (08:09 -0700)
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

cinder/scheduler/filter_scheduler.py
cinder/scheduler/filters/retry_filter.py
cinder/scheduler/host_manager.py
cinder/scheduler/manager.py
cinder/scheduler/scheduler_options.py

index 456adeef237e174bdc78fd1c6fdbf60c23209099..bdeb6178d1e44fa8bc7bf03769ce8e2842a7edf1 100644 (file)
@@ -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
index ae84a4e277d654d891dd1ec111d846d697e56e61..93f16d2cbc8aee5ef2b632634fe36b0960a6962d 100644 (file)
@@ -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
index 9e2c394e7900db078efc421125b349e85862d109..f1f51487baca4a5b09e317306f1d08795c23aae2 100644 (file)
@@ -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)
index 91ba3c5e9d3465aa5037c40381fbb867eeef7cb3..4bef56526502822e64c61fc9b4ae1eb5d0be81be 100644 (file)
@@ -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', {})
index a8010afc6920219b884028d811c3205b504cf898..2917b39770235905a74bb7de810be4bccded3ea1 100644 (file)
@@ -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):