]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
cinder.[brick,db,image] Replace 'locals()'
authorScott DAngelo <scott.dangelo@hp.com>
Tue, 25 Jun 2013 13:19:51 +0000 (13:19 +0000)
committerScott DAngelo <scott.dangelo@hp.com>
Tue, 25 Jun 2013 13:19:51 +0000 (13:19 +0000)
        Replace use of 'locals()' with explicit values.
        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 soruce in the
        cinder brick, db, and image modules, i.e.
        cinder/brick/*.py and subdirectories
        cinder/db/*.py and subdirectories
        cinder/image/*.py and subdirectories

        Partially fixes: bug #1190758

Change-Id: Ibc111ab5ef53a2316e868c9cba8b94b323ba31c0

cinder/brick/iscsi/iscsi.py
cinder/db/sqlalchemy/api.py
cinder/image/glance.py
cinder/image/image_utils.py

index c212771d088f5c35978b1cbf5dee1c0128a5d787..027e2019f0da2d5e8faa2a674f0388b3cbc74fa8 100644 (file)
@@ -184,7 +184,10 @@ class TgtAdm(TargetAdmin):
         if tid is None:
             LOG.error(_("Failed to create iscsi target for volume "
                         "id:%(vol_id)s. Please ensure your tgtd config file "
-                        "contains 'include %(volumes_dir)s/*'") % locals())
+                        "contains 'include %(volumes_dir)s/*'") % {
+                            'vol_id': vol_id,
+                            'volumes_dir': volumes_dir,
+                        })
             raise exception.NotFound()
 
         if old_persist_file is not None and os.path.exists(old_persist_file):
@@ -404,7 +407,7 @@ class LioAdm(TargetAdmin):
             self._execute(*command_args, run_as_root=True)
         except exception.ProcessExecutionError as e:
                 LOG.error(_("Failed to create iscsi target for volume "
-                            "id:%(vol_id)s.") % locals())
+                            "id:%s.") % vol_id)
                 LOG.error("%s" % str(e))
 
                 raise exception.ISCSITargetCreateFailed(volume_id=vol_id)
@@ -413,7 +416,7 @@ class LioAdm(TargetAdmin):
         tid = self._get_target(iqn)
         if tid is None:
             LOG.error(_("Failed to create iscsi target for volume "
-                        "id:%(vol_id)s.") % locals())
+                        "id:%s.") % vol_id)
             raise exception.NotFound()
 
         return tid
@@ -430,7 +433,7 @@ class LioAdm(TargetAdmin):
                           run_as_root=True)
         except exception.ProcessExecutionError as e:
             LOG.error(_("Failed to remove iscsi target for volume "
-                        "id:%(vol_id)s.") % locals())
+                        "id:%s.") % vol_id)
             LOG.error("%s" % str(e))
             raise exception.ISCSITargetRemoveFailed(volume_id=vol_id)
 
index c5735fc85de43f09dda6d6905c2d0a2a652bccc8..2f08c31b0d235d8083af90bd7cf74033b2cc6a68 100644 (file)
@@ -811,7 +811,7 @@ def quota_reserve(context, resources, quotas, deltas, expire,
 
     if unders:
         LOG.warning(_("Change will make usage less than 0 for the following "
-                      "resources: %(unders)s") % locals())
+                      "resources: %s") % unders)
     if overs:
         usages = dict((k, dict(in_use=v['in_use'], reserved=v['reserved']))
                       for k, v in usages.items())
@@ -1829,7 +1829,7 @@ def sm_backend_conf_update(context, sm_backend_id, values):
 
         if not backend_conf:
             raise exception.NotFound(
-                _("No backend config with id %(sm_backend_id)s") % locals())
+                _("No backend config with id %s") % sm_backend_id)
 
         backend_conf.update(values)
         backend_conf.save(session=session)
@@ -1856,7 +1856,7 @@ def sm_backend_conf_get(context, sm_backend_id):
 
     if not result:
         raise exception.NotFound(_("No backend config with id "
-                                   "%(sm_backend_id)s") % locals())
+                                   "%s") % sm_backend_id)
 
     return result
 
@@ -1912,7 +1912,7 @@ def sm_flavor_get(context, sm_flavor_label):
 
     if not result:
         raise exception.NotFound(
-            _("No sm_flavor called %(sm_flavor)s") % locals())
+            _("No sm_flavor called %s") % sm_flavor_label)
 
     return result
 
@@ -1956,7 +1956,7 @@ def sm_volume_get(context, volume_id):
 
     if not result:
         raise exception.NotFound(
-            _("No sm_volume with id %(volume_id)s") % locals())
+            _("No sm_volume with id %s") % volume_id)
 
     return result
 
@@ -2019,7 +2019,7 @@ def backup_update(context, backup_id, values):
 
         if not backup:
             raise exception.BackupNotFound(
-                _("No backup with id %(backup_id)s") % locals())
+                _("No backup with id %s") % backup_id)
 
         backup.update(values)
         backup.save(session=session)
index 80b23911ec586e71fca0913ea56a2b04a67e05f8..f9315e6a88c6bb1f9341868959e872d78f4a5b28 100644 (file)
@@ -152,13 +152,24 @@ class GlanceClientWrapper(object):
                 extra = "retrying"
                 error_msg = _("Error contacting glance server "
                               "'%(netloc)s' for '%(method)s', "
-                              "%(extra)s.")
+                              "%(extra)s.") % {
+                                  'netloc': netloc,
+                                  'method': method,
+                                  'extra': extra,
+                              }
                 if attempt == num_attempts:
                     extra = 'done trying'
-                    LOG.exception(error_msg, locals())
+                    error_msg = _("Error contacting glance server "
+                                  "'%(netloc)s' for '%(method)s', "
+                                  "%(extra)s.") % {
+                                      'netloc': netloc,
+                                      'method': method,
+                                      'extra': extra,
+                                  }
+                    LOG.exception(error_msg)
                     raise exception.GlanceConnectionFailed(netloc=netloc,
                                                            reason=str(e))
-                LOG.exception(error_msg, locals())
+                LOG.exception(error_msg)
                 time.sleep(1)
 
 
index d9b810a1f17cfad8c8a535c5589ca15d87b3379d..d5179af8a50d9b5ebf1bf9e74a2b63bda6b325a3 100644 (file)
@@ -238,7 +238,10 @@ def fetch_to_raw(context, image_service,
             raise exception.ImageUnacceptable(
                 image_id=image_id,
                 reason=_("fmt=%(fmt)s backed by:"
-                         "%(backing_file)s") % locals())
+                         "%(backing_file)s") % {
+                             'fmt': fmt,
+                             'backing_file': backing_file,
+                         })
 
         # NOTE(jdg): I'm using qemu-img convert to write
         # to the volume regardless if it *needs* conversion or not