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
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):
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)
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
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)
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())
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)
if not result:
raise exception.NotFound(_("No backend config with id "
- "%(sm_backend_id)s") % locals())
+ "%s") % sm_backend_id)
return result
if not result:
raise exception.NotFound(
- _("No sm_flavor called %(sm_flavor)s") % locals())
+ _("No sm_flavor called %s") % sm_flavor_label)
return result
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
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)
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)
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