Fix missing translations for log messages

Fixed log translations for error, info and warning messages with
appropriate marker function according to the standards [1].

As LOG.warn has deprecated [2] so I have changed LOG.warn to
LOG.warning.

[1] http://docs.openstack.org/developer/oslo.i18n/guidelines.html
[2] http://bugs.python.org/issue13235

Change-Id: I876c6f3636d511664a25508649e08ad95c40007a
Closes-Bug: 1431256
This commit is contained in:
ankitagrawal 2015-03-18 05:46:59 -07:00 committed by Walter A. Boring IV (hemna)
parent 29739cd234
commit fa22662d2d
5 changed files with 96 additions and 94 deletions

View File

@ -14,7 +14,7 @@
"""Exceptions for the Brick library."""
from os_brick.i18n import _
from os_brick.i18n import _, _LE
from os_brick.openstack.common import log as logging
@ -49,11 +49,11 @@ class BrickException(Exception):
except Exception:
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
msg = (_("Exception in string format operation. msg='%s'")
% self.message)
LOG.exception(msg)
LOG.exception(_LE("Exception in string format operation. "
"msg='%s'"), self.message)
for name, value in kwargs.iteritems():
LOG.error("%s: %s" % (name, value))
LOG.error(_LE("%(name)s: %(value)s"), {'name': name,
'value': value})
# at least get the core message out if something happened
message = self.message

View File

@ -122,7 +122,8 @@ class InitiatorConnector(executor.Executor):
arch=platform.machine(),
*args, **kwargs):
"""Build a Connector object based upon protocol and architecture."""
LOG.debug("Factory for %s on %s" % (protocol, arch))
LOG.debug("Factory for %(protocol)s on %(arch)s",
{'protocol': protocol, 'arch': arch})
protocol = protocol.upper()
if protocol == "ISCSI":
return ISCSIConnector(root_helper=root_helper,
@ -196,7 +197,7 @@ class InitiatorConnector(executor.Executor):
root_helper=self._root_helper)
except putils.ProcessExecutionError as e:
LOG.error(_LE("Failed to access the device on the path "
"%(path)s: %(error)s %(info)s.") %
"%(path)s: %(error)s %(info)s."),
{"path": path, "error": e.stderr,
"info": info})
return False
@ -312,7 +313,7 @@ class ISCSIConnector(InitiatorConnector):
target_props = props
break
else:
LOG.warn(_LW(
LOG.warning(_LW(
'Failed to login to any of the iSCSI targets.'))
host_devices = self._get_device_path(target_props)
@ -325,10 +326,10 @@ class ISCSIConnector(InitiatorConnector):
if tries >= self.device_scan_attempts:
raise exception.VolumeDeviceNotFound(device=host_devices)
LOG.warn(_LW("ISCSI volume not yet found at: %(host_devices)s. "
"Will rescan & retry. Try number: %(tries)s"),
{'host_devices': host_devices,
'tries': tries})
LOG.warning(_LW("ISCSI volume not yet found at: %(host_devices)s. "
"Will rescan & retry. Try number: %(tries)s"),
{'host_devices': host_devices,
'tries': tries})
# The rescan isn't documented as being necessary(?), but it helps
if self.use_multipath:
@ -437,9 +438,8 @@ class ISCSIConnector(InitiatorConnector):
if l.startswith('InitiatorName='):
return l[l.index('=') + 1:].strip()
except putils.ProcessExecutionError:
msg = (_("Could not find the iSCSI Initiator File %s")
% file_path)
LOG.warn(msg)
LOG.warning(_LW("Could not find the iSCSI Initiator File %s"),
file_path)
return None
def _run_iscsiadm(self, connection_properties, iscsi_command, **kwargs):
@ -451,8 +451,8 @@ class ISCSIConnector(InitiatorConnector):
*iscsi_command, run_as_root=True,
root_helper=self._root_helper,
check_exit_code=check_exit_code)
LOG.debug("iscsiadm %s: stdout=%s stderr=%s" %
(iscsi_command, out, err))
LOG.debug("iscsiadm %(iscsi_command)s: stdout=%(out)s stderr=%(err)s",
{'iscsi_command': iscsi_command, 'out': out, 'err': err})
return (out, err)
def _iscsiadm_update(self, connection_properties, property_key,
@ -469,7 +469,7 @@ class ISCSIConnector(InitiatorConnector):
def _disconnect_volume_multipath_iscsi(self, connection_properties,
multipath_name):
"""This removes a multipath device and it's LUNs."""
LOG.debug("Disconnect multipath device %s" % multipath_name)
LOG.debug("Disconnect multipath device %s", multipath_name)
block_devices = self.driver.get_all_block_devices()
devices = []
for dev in block_devices:
@ -566,11 +566,13 @@ class ISCSIConnector(InitiatorConnector):
# exit_code=15 means the session already exists, so it should
# be regarded as successful login.
if err.exit_code not in [15]:
LOG.warn(_LW('Failed to login iSCSI target %(iqn)s '
'on portal %(portal)s (exit code %(err)s).'),
{'iqn': connection_properties['target_iqn'],
'portal': connection_properties['target_portal'],
'err': err.exit_code})
LOG.warning(_LW('Failed to login iSCSI target %(iqn)s '
'on portal %(portal)s (exit code '
'%(err)s).'),
{'iqn': connection_properties['target_iqn'],
'portal': connection_properties[
'target_portal'],
'err': err.exit_code})
return False
self._iscsiadm_update(connection_properties,
@ -630,8 +632,8 @@ class ISCSIConnector(InitiatorConnector):
run_as_root=True,
root_helper=self._root_helper,
check_exit_code=check_exit_code)
LOG.debug("iscsiadm %s: stdout=%s stderr=%s" %
(iscsi_command, out, err))
LOG.debug("iscsiadm %(iscsi_command)s: stdout=%(out)s stderr=%(err)s",
{'iscsi_command': iscsi_command, 'out': out, 'err': err})
return (out, err)
def _run_multipath(self, multipath_command, **kwargs):
@ -641,8 +643,10 @@ class ISCSIConnector(InitiatorConnector):
run_as_root=True,
root_helper=self._root_helper,
check_exit_code=check_exit_code)
LOG.debug("multipath %s: stdout=%s stderr=%s" %
(multipath_command, out, err))
LOG.debug("multipath %(multipath_command)s: "
"stdout=%(out)s stderr=%(err)s",
{'multipath_command': multipath_command,
'out': out, 'err': err})
return (out, err)
def _rescan_iscsi(self):
@ -694,7 +698,7 @@ class FibreChannelConnector(InitiatorConnector):
target_iqn - iSCSI Qualified Name
target_lun - LUN id of the volume
"""
LOG.debug("execute = %s" % self._execute)
LOG.debug("execute = %s", self._execute)
device_info = {'type': 'block'}
hbas = self._linuxfc.get_fc_hbas_info()
@ -706,8 +710,8 @@ class FibreChannelConnector(InitiatorConnector):
if len(host_devices) == 0:
# this is empty because we don't have any FC HBAs
msg = _("We are unable to locate any Fibre Channel devices")
LOG.warn(msg)
LOG.warning(
_LW("We are unable to locate any Fibre Channel devices"))
raise exception.NoFibreChannelHostsFound()
# The /dev/disk/by-path/... node is not always present immediately
@ -726,13 +730,12 @@ class FibreChannelConnector(InitiatorConnector):
raise loopingcall.LoopingCallDone()
if self.tries >= self.device_scan_attempts:
msg = _("Fibre Channel volume device not found.")
LOG.error(msg)
LOG.error(_LE("Fibre Channel volume device not found."))
raise exception.NoFibreChannelVolumeDeviceFound()
LOG.warn(_LW("Fibre volume not yet found. "
"Will rescan & retry. Try number: %(tries)s"),
{'tries': tries})
LOG.warning(_LW("Fibre volume not yet found. "
"Will rescan & retry. Try number: %(tries)s"),
{'tries': tries})
self._linuxfc.rescan_hosts(hbas)
self.tries = self.tries + 1
@ -755,8 +758,8 @@ class FibreChannelConnector(InitiatorConnector):
if self.use_multipath:
mdev_info = self._linuxscsi.find_multipath_device(self.device_name)
if mdev_info is not None:
LOG.debug("Multipath device discovered %(device)s"
% {'device': mdev_info['device']})
LOG.debug("Multipath device discovered %(device)s",
{'device': mdev_info['device']})
device_path = mdev_info['device']
devices = mdev_info['devices']
device_info['multipath_id'] = mdev_info['id']
@ -836,7 +839,7 @@ class FibreChannelConnector(InitiatorConnector):
multipath_id = device_info['multipath_id']
mdev_info = self._linuxscsi.find_multipath_device(multipath_id)
devices = mdev_info['devices']
LOG.debug("devices to remove = %s" % devices)
LOG.debug("devices to remove = %s", devices)
self._linuxscsi.flush_multipath_device(multipath_id)
self._remove_devices(connection_properties, devices)
@ -984,10 +987,10 @@ class AoEConnector(InitiatorConnector):
if waiting_status['tries'] >= self.device_scan_attempts:
raise exception.VolumeDeviceNotFound(device=aoe_path)
LOG.warn(_LW("AoE volume not yet found at: %(path)s. "
"Try number: %(tries)s"),
{'path': aoe_device,
'tries': waiting_status['tries']})
LOG.warning(_LW("AoE volume not yet found at: %(path)s. "
"Try number: %(tries)s"),
{'path': aoe_device,
'tries': waiting_status['tries']})
self._aoe_discover()
waiting_status['tries'] += 1
@ -1023,7 +1026,7 @@ class AoEConnector(InitiatorConnector):
root_helper=self._root_helper,
check_exit_code=0)
LOG.debug('aoe-discover: stdout=%(out)s stderr%(err)s' %
LOG.debug('aoe-discover: stdout=%(out)s stderr%(err)s',
{'out': out, 'err': err})
def _aoe_revalidate(self, aoe_device):
@ -1033,7 +1036,7 @@ class AoEConnector(InitiatorConnector):
root_helper=self._root_helper,
check_exit_code=0)
LOG.debug('aoe-revalidate %(dev)s: stdout=%(out)s stderr%(err)s' %
LOG.debug('aoe-revalidate %(dev)s: stdout=%(out)s stderr%(err)s',
{'dev': aoe_device, 'out': out, 'err': err})
def _aoe_flush(self, aoe_device):
@ -1042,7 +1045,7 @@ class AoEConnector(InitiatorConnector):
run_as_root=True,
root_helper=self._root_helper,
check_exit_code=0)
LOG.debug('aoe-flush %(dev)s: stdout=%(out)s stderr%(err)s' %
LOG.debug('aoe-flush %(dev)s: stdout=%(out)s stderr%(err)s',
{'dev': aoe_device, 'out': out, 'err': err})
@ -1066,8 +1069,8 @@ class RemoteFsConnector(InitiatorConnector):
kwargs.get('glusterfs_mount_point_base') or\
mount_point_base
else:
LOG.warn(_LW("Connection details not present."
" RemoteFsClient may not initialize properly."))
LOG.warning(_LW("Connection details not present."
" RemoteFsClient may not initialize properly."))
self._remotefsclient = remotefs.RemoteFsClient(mount_type, root_helper,
execute=execute,
*args, **kwargs)
@ -1150,8 +1153,8 @@ class HuaweiStorHyperConnector(InitiatorConnector):
self.cli_path = os.getenv('HUAWEISDSHYPERVISORCLI_PATH')
if not self.cli_path:
self.cli_path = '/usr/local/bin/sds/sds_cli'
LOG.debug("CLI path is not configured, using default %s."
% self.cli_path)
LOG.debug("CLI path is not configured, using default %s.",
self.cli_path)
if not os.path.isfile(self.cli_path):
self.iscliexist = False
LOG.error(_LE('SDS CLI file not found, '
@ -1164,8 +1167,8 @@ class HuaweiStorHyperConnector(InitiatorConnector):
@synchronized('connect_volume')
def connect_volume(self, connection_properties):
"""Connect to a volume."""
LOG.debug("Connect_volume connection properties: %s."
% connection_properties)
LOG.debug("Connect_volume connection properties: %s.",
connection_properties)
out = self._attach_volume(connection_properties['volume_id'])
if not out or int(out['ret_code']) not in (self.attached_success_code,
self.has_been_attached_code,
@ -1186,7 +1189,7 @@ class HuaweiStorHyperConnector(InitiatorConnector):
@synchronized('connect_volume')
def disconnect_volume(self, connection_properties, device_info):
"""Disconnect a volume from the local host."""
LOG.debug("Disconnect_volume: %s." % connection_properties)
LOG.debug("Disconnect_volume: %s.", connection_properties)
out = self._detach_volume(connection_properties['volume_id'])
if not out or int(out['ret_code']) not in (self.attached_success_code,
self.vbs_unnormal_code,
@ -1197,8 +1200,8 @@ class HuaweiStorHyperConnector(InitiatorConnector):
def is_volume_connected(self, volume_name):
"""Check if volume already connected to host"""
LOG.debug('Check if volume %s already connected to a host.'
% volume_name)
LOG.debug('Check if volume %s already connected to a host.',
volume_name)
out = self._query_attached_volume(volume_name)
if out:
return int(out['ret_code']) == 0
@ -1225,11 +1228,10 @@ class HuaweiStorHyperConnector(InitiatorConnector):
out, clilog = self._execute(*cmd, run_as_root=False,
root_helper=self._root_helper)
analyse_result = self._analyze_output(out)
LOG.debug('%(method)s volume returns %(analyse_result)s.'
% {'method': method, 'analyse_result': analyse_result})
LOG.debug('%(method)s volume returns %(analyse_result)s.',
{'method': method, 'analyse_result': analyse_result})
if clilog:
LOG.error(_LE("SDS CLI output some log: %s.")
% clilog)
LOG.error(_LE("SDS CLI output some log: %s."), clilog)
return analyse_result
def _analyze_output(self, out):
@ -1238,10 +1240,10 @@ class HuaweiStorHyperConnector(InitiatorConnector):
analyse_result = {}
out_temp = out.split('\n')
for line in out_temp:
LOG.debug("Line is %s." % line)
LOG.debug("Line is %s.", line)
if line.find('=') != -1:
key, val = line.split('=', 1)
LOG.debug(key + " = " + val)
LOG.debug("%(key)s = %(val)s", {'key': key, 'val': val})
if key in ['ret_code', 'ret_desc', 'dev_addr']:
analyse_result[key] = val
return analyse_result

View File

@ -48,13 +48,13 @@ class LinuxFibreChannel(linuxscsi.LinuxSCSI):
# and systool is not installed
# 96 = nova.cmd.rootwrap.RC_NOEXECFOUND:
if exc.exit_code == 96:
LOG.warn(_LW("systool is not installed"))
LOG.warning(_LW("systool is not installed"))
return []
except OSError as exc:
# This handles the case where rootwrap is NOT used
# and systool is not installed
if exc.errno == errno.ENOENT:
LOG.warn(_LW("systool is not installed"))
LOG.warning(_LW("systool is not installed"))
return []
# No FC HBAs were found
@ -173,8 +173,8 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
luns need to be added to the configuration through the
unit_add interface
"""
LOG.debug("Configure lun for s390: device_number=(%(device_num)s) "
"target_wwn=(%(target_wwn)s) target_lun=(%(target_lun)s)",
LOG.debug("Configure lun for s390: device_number=%(device_num)s "
"target_wwn=%(target_wwn)s target_lun=%(target_lun)s",
{'device_num': device_number,
'target_wwn': target_wwn,
'target_lun': lun})
@ -184,9 +184,9 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
try:
self.echo_scsi_command(zfcp_device_command, lun)
except putils.ProcessExecutionError as exc:
msg = _LW("unit_add call for s390 failed exit (%(code)s), "
"stderr (%(stderr)s)")
LOG.warn(msg, {'code': exc.exit_code, 'stderr': exc.stderr})
LOG.warning(_LW("unit_add call for s390 failed exit %(code)s, "
"stderr %(stderr)s"),
{'code': exc.exit_code, 'stderr': exc.stderr})
def deconfigure_scsi_device(self, device_number, target_wwn, lun):
"""Write the LUN to the port's unit_remove attribute.
@ -196,8 +196,8 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
unit_remove interface
"""
LOG.debug("Deconfigure lun for s390: "
"device_number=(%(device_num)s) "
"target_wwn=(%(target_wwn)s) target_lun=(%(target_lun)s)",
"device_number=%(device_num)s "
"target_wwn=%(target_wwn)s target_lun=%(target_lun)s",
{'device_num': device_number,
'target_wwn': target_wwn,
'target_lun': lun})
@ -207,6 +207,6 @@ class LinuxFibreChannelS390X(LinuxFibreChannel):
try:
self.echo_scsi_command(zfcp_device_command, lun)
except putils.ProcessExecutionError as exc:
msg = _LW("unit_remove call for s390 failed exit (%(code)s), "
"stderr (%(stderr)s)")
LOG.warn(msg, {'code': exc.exit_code, 'stderr': exc.stderr})
LOG.warning(_LW("unit_remove call for s390 failed exit %(code)s, "
"stderr %(stderr)s"),
{'code': exc.exit_code, 'stderr': exc.stderr})

View File

@ -22,7 +22,7 @@ import re
from oslo_concurrency import processutils as putils
from os_brick import executor
from os_brick.i18n import _, _LW
from os_brick.i18n import _LW
from os_brick.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@ -62,7 +62,8 @@ class LinuxSCSI(executor.Executor):
# flush any outstanding IO first
self.flush_device_io(device)
LOG.debug("Remove SCSI device(%s) with %s" % (device, path))
LOG.debug("Remove SCSI device %(device)s with %(path)s",
{'device': device, 'path': path})
self.echo_scsi_command(path, "1")
def get_device_info(self, device):
@ -89,11 +90,11 @@ class LinuxSCSI(executor.Executor):
and the multipath device itself.
"""
LOG.debug("remove multipath device %s" % multipath_name)
LOG.debug("remove multipath device %s", multipath_name)
mpath_dev = self.find_multipath_device(multipath_name)
if mpath_dev:
devices = mpath_dev['devices']
LOG.debug("multipath LUNs to remove %s" % devices)
LOG.debug("multipath LUNs to remove %s", devices)
for device in devices:
self.remove_scsi_device(device['device'])
self.flush_multipath_device(mpath_dev['id'])
@ -101,30 +102,29 @@ class LinuxSCSI(executor.Executor):
def flush_device_io(self, device):
"""This is used to flush any remaining IO in the buffers."""
try:
LOG.debug("Flushing IO for device %s" % device)
LOG.debug("Flushing IO for device %s", device)
self._execute('blockdev', '--flushbufs', device, run_as_root=True,
root_helper=self._root_helper)
except putils.ProcessExecutionError as exc:
msg = _("Failed to flush IO buffers prior to removing"
" device: (%(code)s)") % {'code': exc.exit_code}
LOG.warn(msg)
LOG.warning(_LW("Failed to flush IO buffers prior to removing "
"device: %(code)s"), {'code': exc.exit_code})
def flush_multipath_device(self, device):
try:
LOG.debug("Flush multipath device %s" % device)
LOG.debug("Flush multipath device %s", device)
self._execute('multipath', '-f', device, run_as_root=True,
root_helper=self._root_helper)
except putils.ProcessExecutionError as exc:
LOG.warn(_LW("multipath call failed exit (%(code)s)")
% {'code': exc.exit_code})
LOG.warning(_LW("multipath call failed exit %(code)s"),
{'code': exc.exit_code})
def flush_multipath_devices(self):
try:
self._execute('multipath', '-F', run_as_root=True,
root_helper=self._root_helper)
except putils.ProcessExecutionError as exc:
LOG.warn(_LW("multipath call failed exit (%(code)s)")
% {'code': exc.exit_code})
LOG.warning(_LW("multipath call failed exit %(code)s"),
{'code': exc.exit_code})
def find_multipath_device(self, device):
"""Find a multipath device associated with a LUN device name.
@ -140,8 +140,8 @@ class LinuxSCSI(executor.Executor):
run_as_root=True,
root_helper=self._root_helper)
except putils.ProcessExecutionError as exc:
LOG.warn(_LW("multipath call failed exit (%(code)s)")
% {'code': exc.exit_code})
LOG.warning(_LW("multipath call failed exit %(code)s"),
{'code': exc.exit_code})
return None
if out:
@ -163,12 +163,12 @@ class LinuxSCSI(executor.Executor):
mdev_id = mdev_id.replace(')', '')
if mdev is None:
LOG.warn(_LW("Couldn't find multipath device %(line)s")
% {'line': line})
LOG.warning(_LW("Couldn't find multipath device %(line)s"),
{'line': line})
return None
LOG.debug("Found multipath device = %(mdev)s"
% {'mdev': mdev})
LOG.debug("Found multipath device = %(mdev)s",
{'mdev': mdev})
device_lines = lines[3:]
for dev_line in device_lines:
if dev_line.find("policy") != -1:

View File

@ -93,7 +93,7 @@ class RemoteFsClient(object):
mount_path = self.get_mount_point(share)
if mount_path in self._read_mounts():
LOG.info(_LI('Already mounted: %s') % mount_path)
LOG.info(_LI('Already mounted: %s'), mount_path)
return
self._execute('mkdir', '-p', mount_path, check_exit_code=0)
@ -127,8 +127,8 @@ class RemoteFsClient(object):
options = self._nfs_mount_type_opts[mnt_type]
try:
self._do_mount('nfs', nfs_share, mount_path, options, flags)
LOG.debug('Mounted %(sh)s using %(mnt_type)s.'
% {'sh': nfs_share, 'mnt_type': mnt_type})
LOG.debug('Mounted %(sh)s using %(mnt_type)s.',
{'sh': nfs_share, 'mnt_type': mnt_type})
return
except Exception as e:
mnt_errors[mnt_type] = six.text_type(e)