From 598dee274c975f3544e09c9bfe4f676ff4643a49 Mon Sep 17 00:00:00 2001 From: Bharath kumar Date: Fri, 15 Jul 2016 15:20:19 +0000 Subject: [PATCH] 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 --- ironic/conductor/manager.py | 11 +++++------ ironic/drivers/modules/ilo/common.py | 2 +- ironic/drivers/modules/seamicro.py | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index 633c6c2834..45a384715c 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -164,8 +164,8 @@ class ConductorManager(base_manager.BaseConductorManager): """ LOG.debug("RPC change_node_power_state called for node %(node)s. " - "The desired new state is %(state)s." - % {'node': node_id, 'state': new_state}) + "The desired new state is %(state)s.", + {'node': node_id, 'state': new_state}) with task_manager.acquire(context, node_id, shared=False, purpose='changing node power state') as task: @@ -1580,8 +1580,7 @@ class ConductorManager(base_manager.BaseConductorManager): async task """ LOG.debug('RPC set_console_mode called for node %(node)s with ' - 'enabled %(enabled)s' % {'node': node_id, - 'enabled': enabled}) + 'enabled %(enabled)s', {'node': node_id, 'enabled': enabled}) with task_manager.acquire(context, node_id, shared=False, purpose='setting console mode') as task: @@ -2526,8 +2525,8 @@ def _do_inspect_hardware(task): if new_state == states.MANAGEABLE: task.process_event('done') - LOG.info(_LI('Successfully inspected node %(node)s') - % {'node': node.uuid}) + LOG.info(_LI('Successfully inspected node %(node)s'), + {'node': node.uuid}) elif new_state != states.INSPECTING: error = (_("During inspection, driver returned unexpected " "state %(state)s") % {'state': new_state}) diff --git a/ironic/drivers/modules/ilo/common.py b/ironic/drivers/modules/ilo/common.py index f48407a705..32c74ecdca 100644 --- a/ironic/drivers/modules/ilo/common.py +++ b/ironic/drivers/modules/ilo/common.py @@ -708,7 +708,7 @@ def verify_image_checksum(image_location, expected_checksum): LOG.error(_LE("Error opening file: %(file)s"), {'file': image_location}) raise exception.ImageRefValidationFailed(image_href=image_location, - reason=six.text_type(e)) + reason=e) if actual_checksum != expected_checksum: msg = (_('Error verifying image checksum. Image %(image)s failed to ' diff --git a/ironic/drivers/modules/seamicro.py b/ironic/drivers/modules/seamicro.py index 02b05378e1..a57c7a1639 100644 --- a/ironic/drivers/modules/seamicro.py +++ b/ironic/drivers/modules/seamicro.py @@ -24,7 +24,6 @@ import re from oslo_log import log as logging from oslo_service import loopingcall from oslo_utils import importutils -import six from six.moves.urllib import parse as urlparse from ironic.common import boot_devices @@ -564,7 +563,7 @@ class Management(base.ManagementInterface): LOG.error(_LE("Seamicro set boot device failed for node " "%(node)s with the following error: %(error)s"), {'node': task.node.uuid, 'error': ex}) - raise exception.IronicException(message=six.text_type(ex)) + raise exception.IronicException(ex) def get_boot_device(self, task): """Get the current boot device for the task's node.