Merge "Remove translation of log messages"

This commit is contained in:
Jenkins 2017-07-03 17:48:27 +00:00 committed by Gerrit Code Review
commit 65f1f87040
11 changed files with 80 additions and 115 deletions

View File

@ -27,7 +27,6 @@ import six
from ironic_staging_drivers.common import exception
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LE
pywsman = importutils.try_import('pywsman')
@ -119,8 +118,8 @@ class Client(object):
item = 'Fault'
fault = xml_find(doc, _SOAP_ENVELOPE, item)
if fault is not None:
LOG.error(_LE('Call to AMT with URI %(uri)s failed: '
'got Fault %(fault)s'),
LOG.error('Call to AMT with URI %(uri)s failed: '
'got Fault %(fault)s',
{'uri': resource_uri, 'fault': fault.text})
raise exception.AMTFailure(cmd='wsman_get')
return doc
@ -143,9 +142,9 @@ class Client(object):
item = "ReturnValue"
return_value = xml_find(doc, resource_uri, item).text
if return_value != RET_SUCCESS:
LOG.error(_LE("Call to AMT with URI %(uri)s and "
"method %(method)s failed: return value "
"was %(value)s"),
LOG.error("Call to AMT with URI %(uri)s and "
"method %(method)s failed: return value "
"was %(value)s",
{'uri': resource_uri, 'method': method,
'value': return_value})
raise exception.AMTFailure(cmd='wsman_invoke')
@ -246,8 +245,8 @@ def awake_amt_interface(node):
try:
ironic_utils.execute(*cmd_args)
except processutils.ProcessExecutionError as err:
LOG.error(_LE('Unable to awake AMT interface on node '
'%(node_id)s. Error: %(error)s'),
LOG.error('Unable to awake AMT interface on node '
'%(node_id)s. Error: %(error)s',
{'node_id': node.uuid, 'error': err})
raise exception.AMTConnectFailure()
else:

View File

@ -27,8 +27,6 @@ from ironic_staging_drivers.amt import common as amt_common
from ironic_staging_drivers.amt import resource_uris
from ironic_staging_drivers.common import exception
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LE
from ironic_staging_drivers.common.i18n import _LI
pywsman = importutils.try_import('pywsman')
@ -88,13 +86,13 @@ def _set_boot_device_order(node, boot_device):
method, doc)
except (exception.AMTFailure, exception.AMTConnectFailure) as e:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to set boot device %(boot_device)s for "
"node %(node_id)s with error: %(error)s."),
LOG.exception("Failed to set boot device %(boot_device)s for "
"node %(node_id)s with error: %(error)s.",
{'boot_device': boot_device, 'node_id': node.uuid,
'error': e})
else:
LOG.info(_LI("Successfully set boot device %(boot_device)s for "
"node %(node_id)s"),
LOG.info("Successfully set boot device %(boot_device)s for "
"node %(node_id)s",
{'boot_device': boot_device, 'node_id': node.uuid})
@ -142,11 +140,11 @@ def _enable_boot_config(node):
method, doc)
except (exception.AMTFailure, exception.AMTConnectFailure) as e:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to enable boot config for node "
"%(node_id)s with error: %(error)s."),
LOG.exception("Failed to enable boot config for node "
"%(node_id)s with error: %(error)s.",
{'node_id': node.uuid, 'error': e})
else:
LOG.info(_LI("Successfully enabled boot config for node %(node_id)s."),
LOG.info("Successfully enabled boot config for node %(node_id)s.",
{'node_id': node.uuid})

View File

@ -30,9 +30,6 @@ from ironic_staging_drivers.amt import common as amt_common
from ironic_staging_drivers.amt import resource_uris
from ironic_staging_drivers.common import exception
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LE
from ironic_staging_drivers.common.i18n import _LI
from ironic_staging_drivers.common.i18n import _LW
pywsman = importutils.try_import('pywsman')
@ -111,12 +108,12 @@ def _set_power_state(node, target_state):
method, doc)
except (exception.AMTFailure, exception.AMTConnectFailure) as e:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to set power state %(state)s for "
"node %(node_id)s with error: %(error)s."),
LOG.exception("Failed to set power state %(state)s for "
"node %(node_id)s with error: %(error)s.",
{'state': target_state, 'node_id': node.uuid,
'error': e})
else:
LOG.info(_LI("Power state set to %(state)s for node %(node_id)s"),
LOG.info("Power state set to %(state)s for node %(node_id)s",
{'state': target_state, 'node_id': node.uuid})
@ -135,8 +132,8 @@ def _power_status(node):
doc = client.wsman_get(namespace)
except (exception.AMTFailure, exception.AMTConnectFailure) as e:
with excutils.save_and_reraise_exception():
LOG.exception(_LE("Failed to get power state for node %(node_id)s "
"with error: %(error)s."),
LOG.exception("Failed to get power state for node %(node_id)s "
"with error: %(error)s.",
{'node_id': node.uuid, 'error': e})
item = "PowerState"
@ -178,8 +175,8 @@ def _set_and_wait(task, target_state):
if status['iter'] >= CONF.amt_driver.max_attempts:
status['power'] = states.ERROR
LOG.warning(_LW("AMT failed to set power state %(state)s after "
"%(tries)s retries on node %(node_id)s."),
LOG.warning("AMT failed to set power state %(state)s after "
"%(tries)s retries on node %(node_id)s.",
{'state': target_state, 'tries': status['iter'],
'node_id': node.uuid})
raise loopingcall.LoopingCallDone()
@ -188,9 +185,9 @@ def _set_and_wait(task, target_state):
_set_power_state(node, target_state)
except Exception:
# Log failures but keep trying
LOG.warning(_LW("AMT set power state %(state)s for node %(node)s "
"- Attempt %(attempt)s times of %(max_attempt)s "
"failed."),
LOG.warning("AMT set power state %(state)s for node %(node)s "
"- Attempt %(attempt)s times of %(max_attempt)s "
"failed.",
{'state': target_state, 'node': node.uuid,
'attempt': status['iter'] + 1,
'max_attempt': CONF.amt_driver.max_attempts})

View File

@ -34,9 +34,6 @@ import yaml
from ironic.common import dhcp_factory
from ironic.common import exception
from ironic.common.i18n import _
from ironic.common.i18n import _LE
from ironic.common.i18n import _LI
from ironic.common.i18n import _LW
from ironic.common import images
from ironic.common import states
from ironic.common import utils
@ -555,8 +552,8 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
_get_configdrive_path(task.node.uuid))
def take_over(self, task):
LOG.error(_LE("Ansible deploy does not support take over. "
"You must redeploy the node %s explicitly."),
LOG.error("Ansible deploy does not support take over. "
"You must redeploy the node %s explicitly.",
task.node.uuid)
def get_clean_steps(self, task):
@ -602,13 +599,13 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
_run_playbook(playbook, extra_vars, key,
tags=step_tags)
except exception.InstanceDeployFailure as e:
LOG.error(_LE("Ansible failed cleaning step %(step)s "
"on node %(node)s."), {
'node': node.uuid, 'step': stepname})
LOG.error("Ansible failed cleaning step %(step)s "
"on node %(node)s.",
{'node': node.uuid, 'step': stepname})
manager_utils.cleaning_error_handler(task, six.text_type(e))
else:
LOG.info(_LI('Ansible completed cleaning step %(step)s '
'on node %(node)s.'),
LOG.info('Ansible completed cleaning step %(step)s '
'on node %(node)s.',
{'node': node.uuid, 'step': stepname})
@METRICS.timer('AnsibleDeploy.prepare_cleaning')
@ -648,7 +645,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
LOG.debug('Waiting ramdisk on node %s for cleaning', node.uuid)
_run_playbook(playbook, extra_vars, key, tags=['wait'])
LOG.info(_LI('Node %s is ready for cleaning'), node.uuid)
LOG.info('Node %s is ready for cleaning', node.uuid)
@METRICS.timer('AnsibleDeploy.tear_down_cleaning')
def tear_down_cleaning(self, task):
@ -682,7 +679,7 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
@METRICS.timer('AnsibleDeploy.reboot_to_instance')
def reboot_to_instance(self, task):
node = task.node
LOG.info(_LI('Ansible complete deploy on node %s'), node.uuid)
LOG.info('Ansible complete deploy on node %s', node.uuid)
LOG.debug('Rebooting node %s to instance', node.uuid)
manager_utils.node_set_boot_device(task, 'disk', persistent=True)
@ -716,13 +713,12 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
_run_playbook(playbook, extra_vars, key)
_wait_until_powered_off(task)
except Exception as e:
LOG.warning(
_LW('Failed to soft power off node %(node_uuid)s '
'in at least %(timeout)d seconds. '
'Error: %(error)s'),
{'node_uuid': node.uuid,
'timeout': (wait * (attempts - 1)) / 1000,
'error': e})
LOG.warning('Failed to soft power off node %(node_uuid)s '
'in at least %(timeout)d seconds. '
'Error: %(error)s',
{'node_uuid': node.uuid,
'timeout': (wait * (attempts - 1)) / 1000,
'error': e})
# NOTE(pas-ha) flush is a part of deploy playbook
# so if it finished successfully we can safely
# power off the node out-of-band
@ -739,4 +735,4 @@ class AnsibleDeploy(agent_base.HeartbeatMixin, base.DeployInterface):
agent_base.log_and_raise_deployment_error(task, msg)
task.process_event('done')
LOG.info(_LI('Deployment to node %s done'), task.node.uuid)
LOG.info('Deployment to node %s done', task.node.uuid)

View File

@ -18,7 +18,6 @@ from oslo_config import cfg
from oslo_log import log as logging
import pbr.version
from ironic_staging_drivers.common import i18n
CONF = cfg.CONF
DOMAIN = 'ironic'
@ -83,26 +82,21 @@ class CallbackModule(object):
dict(name=name, node=node))
def v2_runner_on_failed(self, result, *args, **kwargs):
LOG.error(i18n._LE(
"Ansible task %(name)s failed on node %(node)s: %(res)s"),
self.runner_msg_dict(result))
LOG.error("Ansible task %(name)s failed on node %(node)s: %(res)s",
self.runner_msg_dict(result))
def v2_runner_on_ok(self, result):
msg_dict = self.runner_msg_dict(result)
if msg_dict['name'] == 'setup':
LOG.info(i18n._LI(
"Ansible task 'setup' complete on node %(node)s"),
msg_dict)
LOG.info("Ansible task 'setup' complete on node %(node)s",
msg_dict)
else:
LOG.info(i18n._LI(
"Ansible task %(name)s complete on node %(node)s: %(res)s"),
msg_dict)
LOG.info("Ansible task %(name)s complete on node %(node)s: "
"%(res)s", msg_dict)
def v2_runner_on_unreachable(self, result):
LOG.error(i18n._LE(
"Node %(node)s was unreachable for Ansible task %(name)s: "
"%(res)s"),
self.runner_msg_dict(result))
LOG.error("Node %(node)s was unreachable for Ansible task %(name)s: "
"%(res)s", self.runner_msg_dict(result))
def v2_runner_on_async_poll(self, result):
LOG.debug("Polled ansible task %(name)s for complete "
@ -110,14 +104,12 @@ class CallbackModule(object):
self.runner_msg_dict(result))
def v2_runner_on_async_ok(self, result):
LOG.info(i18n._LI(
"Async Ansible task %(name)s complete on node %(node)s: %(res)s"),
self.runner_msg_dict(result))
LOG.info("Async Ansible task %(name)s complete on node %(node)s: "
"%(res)s", self.runner_msg_dict(result))
def v2_runner_on_async_failed(self, result):
LOG.error(i18n._LE(
"Async Ansible task %(name)s failed on node %(node)s: %(res)s"),
self.runner_msg_dict(result))
LOG.error("Async Ansible task %(name)s failed on node %(node)s: "
"%(res)s", self.runner_msg_dict(result))
def v2_runner_on_skipped(self, result):
LOG.debug("Ansible task %(name)s skipped on node %(node)s: %(res)s",

View File

@ -19,8 +19,6 @@ try:
except ImportError:
HAS_PYUDEV = False
from ironic_staging_drivers.common.i18n import _LW
COLLECT_INFO = (('wwn', 'WWN'), ('serial', 'SERIAL_SHORT'),
('wwn_with_extension', 'WWN_WITH_EXTENSION'),
@ -30,10 +28,10 @@ COLLECT_INFO = (('wwn', 'WWN'), ('serial', 'SERIAL_SHORT'),
def get_devices_wwn(devices):
if not HAS_PYUDEV:
LOG.warning(_LW('Can not collect "wwn", "wwn_with_extension", '
'"wwn_vendor_extension" and "serial" when using '
'root device hints because there\'s no UDEV python '
'binds installed'))
LOG.warning('Can not collect "wwn", "wwn_with_extension", '
'"wwn_vendor_extension" and "serial" when using '
'root device hints because there\'s no UDEV python '
'binds installed')
return
dev_dict = {}
@ -43,8 +41,8 @@ def get_devices_wwn(devices):
try:
udev = pyudev.Device.from_device_file(context, name)
except (ValueError, EnvironmentError, pyudev.DeviceNotFoundError) as e:
LOG.warning(_LW('Device %(dev)s is inaccessible, skipping... '
'Error: %(error)s'), {'dev': name, 'error': e})
LOG.warning('Device %(dev)s is inaccessible, skipping... '
'Error: %(error)s', {'dev': name, 'error': e})
continue
dev_dict[device] = {}

View File

@ -19,13 +19,3 @@ _translators = i18n.TranslatorFactory(domain='ironic-staging-drivers')
# The primary translation function using the well-known name "_"
_ = _translators.primary
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical

View File

@ -30,7 +30,6 @@ from oslo_utils import importutils
import six
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LW
from ironic_staging_drivers.common import utils
iboot = importutils.try_import('iboot')
@ -127,9 +126,9 @@ def _switch(driver_info, enabled):
def _wait_for_switch(mutable):
if mutable['retries'] > CONF.iboot.max_retry:
LOG.warning(_LW(
LOG.warning(
'Reached maximum number of attempts (%(attempts)d) to set '
'power state for node %(node)s to "%(op)s"'),
'power state for node %(node)s to "%(op)s"',
{'attempts': mutable['retries'], 'node': driver_info['uuid'],
'op': states.POWER_ON if enabled else states.POWER_OFF})
raise loopingcall.LoopingCallDone()
@ -140,8 +139,8 @@ def _switch(driver_info, enabled):
if mutable['response']:
raise loopingcall.LoopingCallDone()
except (TypeError, IndexError):
LOG.warning(_LW("Cannot call set power state for node '%(node)s' "
"at relay '%(relay)s'. iBoot switch() failed."),
LOG.warning("Cannot call set power state for node '%(node)s' "
"at relay '%(relay)s'. iBoot switch() failed.",
{'node': driver_info['uuid'], 'relay': relay_id})
mutable = {'response': False, 'retries': 0}
@ -175,9 +174,9 @@ def _power_status(driver_info):
def _wait_for_power_status(mutable):
if mutable['retries'] > CONF.iboot.max_retry:
LOG.warning(_LW(
LOG.warning(
'Reached maximum number of attempts (%(attempts)d) to get '
'power state for node %(node)s'),
'power state for node %(node)s',
{'attempts': mutable['retries'], 'node': driver_info['uuid']})
raise loopingcall.LoopingCallDone()
@ -191,8 +190,8 @@ def _power_status(driver_info):
mutable['state'] = states.POWER_OFF
raise loopingcall.LoopingCallDone()
except (TypeError, IndexError):
LOG.warning(_LW("Cannot get power state for node '%(node)s' at "
"relay '%(relay)s'. iBoot get_relays() failed."),
LOG.warning("Cannot get power state for node '%(node)s' at "
"relay '%(relay)s'. iBoot get_relays() failed.",
{'node': driver_info['uuid'], 'relay': relay_id})
mutable = {'state': states.ERROR, 'retries': 0}

View File

@ -21,7 +21,6 @@ import six
from ironic_staging_drivers.common import exception
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LW
LOG = log.getLogger(__name__)
@ -500,8 +499,8 @@ def parse_statistics(raw_data):
except exception.InvalidIPMITimestamp as e:
# there is not "bad time" in standard, reset to start the epoch
statistics['timestamp'] = _INVALID_TIME
LOG.warning(_LW('Invalid timestamp in Node Nanager statistics '
'data: %s'), six.text_type(e))
LOG.warning('Invalid timestamp in Node Nanager statistics '
'data: %s', six.text_type(e))
else:
statistics['timestamp'] = isotime

View File

@ -25,8 +25,6 @@ from oslo_utils import excutils
import six
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LE
from ironic_staging_drivers.common.i18n import _LI
from ironic_staging_drivers.intel_nm import nm_commands
@ -67,7 +65,7 @@ def _get_nm_address(task):
if channel is False and address is False:
raise exception.IPMIFailure(_('Driver data indicates that Intel '
'Node Manager detection failed.'))
LOG.info(_LI('Start detection of Intel Node Manager on node %s'),
LOG.info('Start detection of Intel Node Manager on node %s',
node.uuid)
sdr_filename = os.path.join(CONF.tempdir, node.uuid + '.sdr')
res = None
@ -115,8 +113,8 @@ def _execute_nm_command(task, data, command_func, parse_func=None):
channel, address = _get_nm_address(task)
except exception.IPMIFailure as e:
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Can not obtain Intel Node Manager address for '
'node %(node)s: %(err)s'),
LOG.exception('Can not obtain Intel Node Manager address for '
'node %(node)s: %(err)s',
{'node': task.node.uuid, 'err': six.text_type(e)})
driver_info = task.node.driver_info
driver_info['ipmi_bridging'] = 'single'
@ -129,9 +127,9 @@ def _execute_nm_command(task, data, command_func, parse_func=None):
return parse_func(out.split())
except exception.IPMIFailure as e:
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Error in returned data for node %(node)s: '
'%(err)s'), {'node': task.node.uuid,
'err': six.text_type(e)})
LOG.exception('Error in returned data for node %(node)s: '
'%(err)s', {'node': task.node.uuid,
'err': six.text_type(e)})
class IntelNMVendorPassthru(base.VendorInterface):

View File

@ -29,7 +29,6 @@ from oslo_log import log
from ironic_staging_drivers.common import exception
from ironic_staging_drivers.common.i18n import _
from ironic_staging_drivers.common.i18n import _LI
from ironic_staging_drivers.common import utils
@ -154,9 +153,9 @@ class WakeOnLanPower(base.PowerInterface):
if pstate == states.POWER_ON:
_send_magic_packets(task, params['host'], params['port'])
elif pstate == states.POWER_OFF:
LOG.info(_LI('Power off called for node %s. Wake-On-Lan does not '
'support this operation. Manual intervention '
'required to perform this action.'), node.uuid)
LOG.info('Power off called for node %s. Wake-On-Lan does not '
'support this operation. Manual intervention '
'required to perform this action.', node.uuid)
else:
raise ironic_exception.InvalidParameterValue(_(
"set_power_state called for Node %(node)s with invalid "
@ -177,9 +176,9 @@ class WakeOnLanPower(base.PowerInterface):
magic packets
"""
LOG.info(_LI('Reboot called for node %s. Wake-On-Lan does '
'not fully support this operation. Trying to '
'power on the node.'), task.node.uuid)
LOG.info('Reboot called for node %s. Wake-On-Lan does '
'not fully support this operation. Trying to '
'power on the node.', task.node.uuid)
self.set_power_state(task, states.POWER_ON)
def get_supported_power_states(self, task):