Following the hacking rule for string interpolation at logging

String interpolation should be delayed to be handled
by the logging code, rather than being done
at the point of the logging call.

See the oslo i18n guideline.

* http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages

* http://docs.openstack.org/developer/oslo.i18n/guidelines.html#avoid-forcing-the-translation-of-translatable-variables


Change-Id: I96eaede777ca60c7ba2b83ea6968108910b62953
Closes-Bug: #1596829
This commit is contained in:
Bharath kumar 2016-07-15 15:20:19 +00:00 committed by Bharath kumar
parent 02589163d5
commit 598dee274c
3 changed files with 7 additions and 9 deletions

View File

@ -164,8 +164,8 @@ class ConductorManager(base_manager.BaseConductorManager):
""" """
LOG.debug("RPC change_node_power_state called for node %(node)s. " LOG.debug("RPC change_node_power_state called for node %(node)s. "
"The desired new state is %(state)s." "The desired new state is %(state)s.",
% {'node': node_id, 'state': new_state}) {'node': node_id, 'state': new_state})
with task_manager.acquire(context, node_id, shared=False, with task_manager.acquire(context, node_id, shared=False,
purpose='changing node power state') as task: purpose='changing node power state') as task:
@ -1580,8 +1580,7 @@ class ConductorManager(base_manager.BaseConductorManager):
async task async task
""" """
LOG.debug('RPC set_console_mode called for node %(node)s with ' LOG.debug('RPC set_console_mode called for node %(node)s with '
'enabled %(enabled)s' % {'node': node_id, 'enabled %(enabled)s', {'node': node_id, 'enabled': enabled})
'enabled': enabled})
with task_manager.acquire(context, node_id, shared=False, with task_manager.acquire(context, node_id, shared=False,
purpose='setting console mode') as task: purpose='setting console mode') as task:
@ -2526,8 +2525,8 @@ def _do_inspect_hardware(task):
if new_state == states.MANAGEABLE: if new_state == states.MANAGEABLE:
task.process_event('done') task.process_event('done')
LOG.info(_LI('Successfully inspected node %(node)s') LOG.info(_LI('Successfully inspected node %(node)s'),
% {'node': node.uuid}) {'node': node.uuid})
elif new_state != states.INSPECTING: elif new_state != states.INSPECTING:
error = (_("During inspection, driver returned unexpected " error = (_("During inspection, driver returned unexpected "
"state %(state)s") % {'state': new_state}) "state %(state)s") % {'state': new_state})

View File

@ -708,7 +708,7 @@ def verify_image_checksum(image_location, expected_checksum):
LOG.error(_LE("Error opening file: %(file)s"), LOG.error(_LE("Error opening file: %(file)s"),
{'file': image_location}) {'file': image_location})
raise exception.ImageRefValidationFailed(image_href=image_location, raise exception.ImageRefValidationFailed(image_href=image_location,
reason=six.text_type(e)) reason=e)
if actual_checksum != expected_checksum: if actual_checksum != expected_checksum:
msg = (_('Error verifying image checksum. Image %(image)s failed to ' msg = (_('Error verifying image checksum. Image %(image)s failed to '

View File

@ -24,7 +24,6 @@ import re
from oslo_log import log as logging from oslo_log import log as logging
from oslo_service import loopingcall from oslo_service import loopingcall
from oslo_utils import importutils from oslo_utils import importutils
import six
from six.moves.urllib import parse as urlparse from six.moves.urllib import parse as urlparse
from ironic.common import boot_devices from ironic.common import boot_devices
@ -564,7 +563,7 @@ class Management(base.ManagementInterface):
LOG.error(_LE("Seamicro set boot device failed for node " LOG.error(_LE("Seamicro set boot device failed for node "
"%(node)s with the following error: %(error)s"), "%(node)s with the following error: %(error)s"),
{'node': task.node.uuid, 'error': ex}) {'node': task.node.uuid, 'error': ex})
raise exception.IronicException(message=six.text_type(ex)) raise exception.IronicException(ex)
def get_boot_device(self, task): def get_boot_device(self, task):
"""Get the current boot device for the task's node. """Get the current boot device for the task's node.