From 4676a47697fb419aacd8248c662556e6952935d6 Mon Sep 17 00:00:00 2001 From: Vladyslav Drok Date: Wed, 3 Sep 2014 11:42:53 +0300 Subject: Translator functions cleanup part 2 This part fixes ironic/drivers folder. Some modules use _ function for log translation, even when the translated string is passed to e.g. LOG.warn function. This patch fixes it, using translator functions appropriate for corresponding log levels. Translator functions, imported from ironic.openstack.common.gettextutils are now imported from ironic.common.i18n. Translator functions are imported the same way across all modules. All places that are changed conform to http://docs.openstack.org/developer/oslo.i18n/guidelines.html Partial-bug: #1364813 Change-Id: I77cf2582d2e9173d57da473cba118fd8b48a8735 --- ironic/drivers/fake.py | 4 ++-- ironic/drivers/modules/agent.py | 12 +++++------ ironic/drivers/modules/console_utils.py | 9 +++----- ironic/drivers/modules/deploy_utils.py | 27 ++++++++++++------------ ironic/drivers/modules/drac/management.py | 6 ++---- ironic/drivers/modules/drac/power.py | 4 +--- ironic/drivers/modules/iboot.py | 4 +--- ironic/drivers/modules/ilo/common.py | 11 +++++----- ironic/drivers/modules/ilo/deploy.py | 6 ++---- ironic/drivers/modules/ilo/power.py | 13 ++++++------ ironic/drivers/modules/image_cache.py | 25 +++++++++++----------- ironic/drivers/modules/ipminative.py | 35 +++++++++++++++---------------- ironic/drivers/modules/ipmitool.py | 27 ++++++++++++------------ ironic/drivers/modules/iscsi_deploy.py | 6 ++---- ironic/drivers/modules/pxe.py | 10 +++------ ironic/drivers/modules/seamicro.py | 17 +++++++-------- ironic/drivers/modules/snmp.py | 4 +--- ironic/drivers/modules/ssh.py | 8 +++---- ironic/drivers/pxe.py | 4 ++-- 19 files changed, 104 insertions(+), 128 deletions(-) (limited to 'ironic/drivers') diff --git a/ironic/drivers/fake.py b/ironic/drivers/fake.py index 7956792e8..3bd0f82ba 100644 --- a/ironic/drivers/fake.py +++ b/ironic/drivers/fake.py @@ -99,7 +99,7 @@ class FakeSeaMicroDriver(base.BaseDriver): if not importutils.try_import('seamicroclient'): raise exception.DriverLoadError( driver=self.__class__.__name__, - reason="Unable to import seamicroclient library") + reason=_("Unable to import seamicroclient library")) self.power = seamicro.Power() self.deploy = fake.FakeDeploy() self.management = seamicro.Management() @@ -156,6 +156,6 @@ class FakeSNMPDriver(base.BaseDriver): if not importutils.try_import('pysnmp'): raise exception.DriverLoadError( driver=self.__class__.__name__, - reason="Unable to import pysnmp library") + reason=_("Unable to import pysnmp library")) self.power = snmp.SNMPPower() self.deploy = fake.FakeDeploy() diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py index 2ba5740b1..d1e9e18af 100644 --- a/ironic/drivers/modules/agent.py +++ b/ironic/drivers/modules/agent.py @@ -20,8 +20,9 @@ from oslo.utils import excutils from ironic.common import dhcp_factory from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LW from ironic.common import image_service from ironic.common import keystone from ironic.common import paths @@ -38,9 +39,6 @@ from ironic.openstack.common import fileutils from ironic.openstack.common import log -_LE = i18n._LE -_LW = i18n._LW - agent_opts = [ cfg.StrOpt('agent_pxe_append_params', default='nofb nomodeset vga=normal', @@ -379,7 +377,7 @@ class AgentVendorInterface(base.VendorInterface): except Exception: # catch-all in case something bubbles up here with excutils.save_and_reraise_exception(): - LOG.exception(_('vendor_passthru failed with method %s'), + LOG.exception(_LE('vendor_passthru failed with method %s'), method) def _heartbeat(self, task, **kwargs): @@ -583,8 +581,8 @@ class AgentVendorInterface(base.VendorInterface): node = objects.Node.get_by_id(context, node_id) except exception.NodeNotFound: with excutils.save_and_reraise_exception(): - LOG.exception(_('Could not find matching node for the ' - 'provided MACs %s.'), mac_addresses) + LOG.exception(_LE('Could not find matching node for the ' + 'provided MACs %s.'), mac_addresses) return node diff --git a/ironic/drivers/modules/console_utils.py b/ironic/drivers/modules/console_utils.py index 21648e9da..5a58d8414 100644 --- a/ironic/drivers/modules/console_utils.py +++ b/ironic/drivers/modules/console_utils.py @@ -27,16 +27,14 @@ import time from oslo.config import cfg from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LW from ironic.common import utils from ironic.openstack.common import log as logging from ironic.openstack.common import loopingcall from ironic.openstack.common import processutils -_LW = i18n._LW - opts = [ cfg.StrOpt('terminal', default='shellinaboxd', @@ -260,9 +258,8 @@ def stop_shellinabox_console(node_uuid): try: _stop_console(node_uuid) except exception.NoConsolePid: - LOG.warning(_("No console pid found for node %s" - " while trying to stop shellinabox console.") - % node_uuid) + LOG.warning(_LW("No console pid found for node %s while trying to " + "stop shellinabox console."), node_uuid) except processutils.ProcessExecutionError as exc: msg = (_("Could not stop the console for node '%(node)s'. " "Reason: %(err)s.") % {'node': node_uuid, 'err': exc}) diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 7e84f885c..8901fe1fc 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -26,6 +26,7 @@ from oslo.utils import excutils from ironic.common import disk_partitioner from ironic.common import exception from ironic.common.i18n import _ +from ironic.common.i18n import _LE from ironic.common import utils from ironic.drivers.modules import image_cache from ironic.openstack.common import log as logging @@ -232,8 +233,8 @@ def destroy_disk_metadata(dev, node_uuid): check_exit_code=[0]) except processutils.ProcessExecutionError as err: with excutils.save_and_reraise_exception(): - LOG.error(_("Failed to erase beginning of disk for node " - "%(node)s. Command: %(command)s. Error: %(error)s."), + LOG.error(_LE("Failed to erase beginning of disk for node " + "%(node)s. Command: %(command)s. Error: %(error)s."), {'node': node_uuid, 'command': err.cmd, 'error': err.stderr}) @@ -244,8 +245,8 @@ def destroy_disk_metadata(dev, node_uuid): block_sz = get_dev_block_size(dev) except processutils.ProcessExecutionError as err: with excutils.save_and_reraise_exception(): - LOG.error(_("Failed to get disk block count for node %(node)s. " - "Command: %(command)s. Error: %(error)s."), + LOG.error(_LE("Failed to get disk block count for node %(node)s. " + "Command: %(command)s. Error: %(error)s."), {'node': node_uuid, 'command': err.cmd, 'error': err.stderr}) @@ -257,9 +258,9 @@ def destroy_disk_metadata(dev, node_uuid): run_as_root=True, check_exit_code=[0]) except processutils.ProcessExecutionError as err: with excutils.save_and_reraise_exception(): - LOG.error(_("Failed to erase the end of the disk on node " - "%(node)s. Command: %(command)s. " - "Error: %(error)s."), + LOG.error(_LE("Failed to erase the end of the disk on node " + "%(node)s. Command: %(command)s. " + "Error: %(error)s."), {'node': node_uuid, 'command': err.cmd, 'error': err.stderr}) @@ -322,7 +323,7 @@ def work_on_disk(dev, root_mb, swap_mb, ephemeral_mb, ephemeral_format, root_uuid = block_uuid(root_part) except processutils.ProcessExecutionError: with excutils.save_and_reraise_exception(): - LOG.error(_("Failed to detect root device UUID.")) + LOG.error(_LE("Failed to detect root device UUID.")) return root_uuid @@ -360,13 +361,13 @@ def deploy(address, port, iqn, lun, image_path, preserve_ephemeral) except processutils.ProcessExecutionError as err: with excutils.save_and_reraise_exception(): - LOG.error(_("Deploy to address %s failed.") % address) - LOG.error(_("Command: %s") % err.cmd) - LOG.error(_("StdOut: %r") % err.stdout) - LOG.error(_("StdErr: %r") % err.stderr) + LOG.error(_LE("Deploy to address %s failed."), address) + LOG.error(_LE("Command: %s"), err.cmd) + LOG.error(_LE("StdOut: %r"), err.stdout) + LOG.error(_LE("StdErr: %r"), err.stderr) except exception.InstanceDeployFailure as e: with excutils.save_and_reraise_exception(): - LOG.error(_("Deploy to address %s failed.") % address) + LOG.error(_LE("Deploy to address %s failed."), address) LOG.error(e) finally: logout_iscsi(address, port, iqn) diff --git a/ironic/drivers/modules/drac/management.py b/ironic/drivers/modules/drac/management.py index 4598f078b..c82ff6547 100644 --- a/ironic/drivers/modules/drac/management.py +++ b/ironic/drivers/modules/drac/management.py @@ -21,7 +21,8 @@ DRAC Management Driver from ironic.common import boot_devices from ironic.common import exception -from ironic.common import i18n +from ironic.common.i18n import _ +from ironic.common.i18n import _LE from ironic.drivers import base from ironic.drivers.modules.drac import common as drac_common from ironic.drivers.modules.drac import resource_uris @@ -33,9 +34,6 @@ pywsman = importutils.try_import('pywsman') LOG = logging.getLogger(__name__) -_ = i18n._ -_LE = i18n._LE - _BOOT_DEVICES_MAP = { boot_devices.DISK: 'HardDisk', boot_devices.PXE: 'NIC', diff --git a/ironic/drivers/modules/drac/power.py b/ironic/drivers/modules/drac/power.py index b53281724..3e142da53 100644 --- a/ironic/drivers/modules/drac/power.py +++ b/ironic/drivers/modules/drac/power.py @@ -16,7 +16,7 @@ DRAC Power Driver using the Base Server Profile """ from ironic.common import exception -from ironic.common import i18n +from ironic.common.i18n import _LE from ironic.common import states from ironic.drivers import base from ironic.drivers.modules.drac import common as drac_common @@ -29,8 +29,6 @@ pywsman = importutils.try_import('pywsman') LOG = logging.getLogger(__name__) -_LE = i18n._LE - POWER_STATES = { '2': states.POWER_ON, '3': states.POWER_OFF, diff --git a/ironic/drivers/modules/iboot.py b/ironic/drivers/modules/iboot.py index b2760bfed..15839fdd5 100644 --- a/ironic/drivers/modules/iboot.py +++ b/ironic/drivers/modules/iboot.py @@ -22,8 +22,8 @@ Ironic iBoot PDU power manager. from oslo.utils import importutils from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base @@ -32,8 +32,6 @@ from ironic.openstack.common import log as logging iboot = importutils.try_import('iboot') -_LW = i18n._LW - LOG = logging.getLogger(__name__) REQUIRED_PROPERTIES = { diff --git a/ironic/drivers/modules/ilo/common.py b/ironic/drivers/modules/ilo/common.py index 77e52c2e1..15be181b9 100644 --- a/ironic/drivers/modules/ilo/common.py +++ b/ironic/drivers/modules/ilo/common.py @@ -22,8 +22,9 @@ from oslo.config import cfg from oslo.utils import importutils from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LI from ironic.common import images from ironic.common import swift from ironic.common import utils @@ -56,9 +57,6 @@ CONF.register_opts(opts, group='ilo') LOG = logging.getLogger(__name__) -_LE = i18n._LE -_LI = i18n._LI - REQUIRED_PROPERTIES = { 'ilo_address': _("IP address or hostname of the iLO. Required."), 'ilo_username': _("username for the iLO with administrator privileges. " @@ -272,7 +270,7 @@ def set_boot_device(node, device): raise exception.IloOperationError(operation=operation, error=ilo_exception) - LOG.debug(_LI("Node %(uuid)s set to boot from %(device)s."), + LOG.debug("Node %(uuid)s set to boot from %(device)s.", {'uuid': node.uuid, 'device': device}) @@ -293,7 +291,8 @@ def setup_vmedia_for_boot(task, boot_iso, parameters=None): :raises: ImageCreationFailed, if it failed while creating the floppy image. :raises: IloOperationError, if attaching virtual media failed. """ - LOG.info("Setting up node %s to boot from virtual media", task.node.uuid) + LOG.info(_LI("Setting up node %s to boot from virtual media"), + task.node.uuid) if parameters: floppy_image_temp_url = _prepare_floppy_image(task, parameters) diff --git a/ironic/drivers/modules/ilo/deploy.py b/ironic/drivers/modules/ilo/deploy.py index d77a6594b..4763bad5f 100644 --- a/ironic/drivers/modules/ilo/deploy.py +++ b/ironic/drivers/modules/ilo/deploy.py @@ -20,8 +20,9 @@ import tempfile from oslo.config import cfg from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LI from ironic.common import images from ironic.common import states from ironic.common import swift @@ -36,9 +37,6 @@ from ironic.openstack.common import log as logging LOG = logging.getLogger(__name__) -_LE = i18n._LE -_LI = i18n._LI - CONF = cfg.CONF REQUIRED_PROPERTIES = { diff --git a/ironic/drivers/modules/ilo/power.py b/ironic/drivers/modules/ilo/power.py index bf1d73181..b799fb69a 100644 --- a/ironic/drivers/modules/ilo/power.py +++ b/ironic/drivers/modules/ilo/power.py @@ -21,6 +21,7 @@ from oslo.utils import importutils from ironic.common import exception from ironic.common.i18n import _ +from ironic.common.i18n import _LE from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base @@ -79,8 +80,8 @@ def _get_power_state(node): power_status = ilo_object.get_host_power_status() except ilo_client.IloError as ilo_exception: - LOG.error(_("iLO get_power_state failed for node %(node_id)s with " - "error: %(error)s."), + LOG.error(_LE("iLO get_power_state failed for node %(node_id)s with " + "error: %(error)s."), {'node_id': node.uuid, 'error': ilo_exception}) operation = _('iLO get_power_status') raise exception.IloOperationError(operation=operation, @@ -151,8 +152,8 @@ def _set_power_state(task, target_state): raise exception.InvalidParameterValue(msg) except ilo_client.IloError as ilo_exception: - LOG.error(_("iLO set_power_state failed to set state to %(tstate)s " - " for node %(node_id)s with error: %(error)s"), + LOG.error(_LE("iLO set_power_state failed to set state to %(tstate)s " + " for node %(node_id)s with error: %(error)s"), {'tstate': target_state, 'node_id': node.uuid, 'error': ilo_exception}) operation = _('iLO set_power_state') @@ -164,8 +165,8 @@ def _set_power_state(task, target_state): if state != target_state: timeout = (CONF.ilo.power_wait) * (CONF.ilo.power_retry) - LOG.error(_("iLO failed to change state to %(tstate)s " - "within %(timeout)s sec"), + LOG.error(_LE("iLO failed to change state to %(tstate)s " + "within %(timeout)s sec"), {'tstate': target_state, 'timeout': timeout}) raise exception.PowerStateFailure(pstate=target_state) diff --git a/ironic/drivers/modules/image_cache.py b/ironic/drivers/modules/image_cache.py index d7f0c714e..2765c18c0 100644 --- a/ironic/drivers/modules/image_cache.py +++ b/ironic/drivers/modules/image_cache.py @@ -26,7 +26,8 @@ from oslo.config import cfg from ironic.common import exception from ironic.common.glance_service import service_utils -from ironic.common.i18n import _ +from ironic.common.i18n import _LI +from ironic.common.i18n import _LW from ironic.common import images from ironic.common import utils from ironic.openstack.common import fileutils @@ -114,8 +115,8 @@ class ImageCache(object): with lockutils.lock('master_image', 'ironic-'): os.link(master_path, dest_path) except OSError: - LOG.info(_("Master cache miss for image %(uuid)s, " - "starting download") % + LOG.info(_LI("Master cache miss for image %(uuid)s, " + "starting download"), {'uuid': uuid}) else: LOG.debug("Master cache hit for image %(uuid)s", @@ -174,8 +175,8 @@ class ImageCache(object): return amount = self._clean_up_ensure_cache_size(survived, amount) if amount is not None and amount > 0: - LOG.warn(_("Cache clean up was unable to reclaim %(required)d MiB " - "of disk space, still %(left)d MiB required"), + LOG.warn(_LW("Cache clean up was unable to reclaim %(required)d " + "MiB of disk space, still %(left)d MiB required"), {'required': amount_copy / 1024 / 1024, 'left': amount / 1024 / 1024}) @@ -201,8 +202,8 @@ class ImageCache(object): try: os.unlink(file_name) except EnvironmentError as exc: - LOG.warn(_("Unable to delete file %(name)s from " - "master image cache: %(exc)s") % + LOG.warn(_LW("Unable to delete file %(name)s from " + "master image cache: %(exc)s"), {'name': file_name, 'exc': exc}) else: if amount is not None: @@ -239,8 +240,8 @@ class ImageCache(object): try: os.unlink(file_name) except EnvironmentError as exc: - LOG.warn(_("Unable to delete file %(name)s from " - "master image cache: %(exc)s") % + LOG.warn(_LW("Unable to delete file %(name)s from " + "master image cache: %(exc)s"), {'name': file_name, 'exc': exc}) else: total_size -= stat.st_size @@ -248,9 +249,9 @@ class ImageCache(object): amount -= stat.st_size if total_size > self._cache_size: - LOG.info(_("After cleaning up cache dir %(dir)s " - "cache size %(actual)d is still larger than " - "threshold %(expected)d") % + LOG.info(_LI("After cleaning up cache dir %(dir)s " + "cache size %(actual)d is still larger than " + "threshold %(expected)d"), {'dir': self.master_dir, 'actual': total_size, 'expected': self._cache_size}) return max(amount, 0) diff --git a/ironic/drivers/modules/ipminative.py b/ironic/drivers/modules/ipminative.py index a26e203ce..ce2285408 100644 --- a/ironic/drivers/modules/ipminative.py +++ b/ironic/drivers/modules/ipminative.py @@ -28,8 +28,9 @@ from oslo.utils import importutils from ironic.common import boot_devices from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -54,8 +55,6 @@ opts = [ 'Recommended setting is 5 seconds.'), ] -_LE = i18n._LE - CONF = cfg.CONF CONF.register_opts(opts, group='ipmi') @@ -132,8 +131,8 @@ def _power_on(driver_info): from ipmi. """ - msg = _("IPMI power on failed for node %(node_id)s with the " - "following error: %(error)s") + msg = _LW("IPMI power on failed for node %(node_id)s with the " + "following error: %(error)s") try: ipmicmd = ipmi_command.Command(bmc=driver_info['address'], userid=driver_info['username'], @@ -141,14 +140,14 @@ def _power_on(driver_info): wait = CONF.ipmi.retry_timeout ret = ipmicmd.set_power('on', wait) except pyghmi_exception.IpmiException as e: - LOG.warning(msg % {'node_id': driver_info['uuid'], 'error': str(e)}) + LOG.warning(msg, {'node_id': driver_info['uuid'], 'error': str(e)}) raise exception.IPMIFailure(cmd=str(e)) state = ret.get('powerstate') if state == 'on': return states.POWER_ON else: - LOG.warning(msg % {'node_id': driver_info['uuid'], 'error': ret}) + LOG.warning(msg, {'node_id': driver_info['uuid'], 'error': ret}) raise exception.PowerStateFailure(pstate=state) @@ -162,8 +161,8 @@ def _power_off(driver_info): from ipmi. """ - msg = _("IPMI power off failed for node %(node_id)s with the " - "following error: %(error)s") + msg = _LW("IPMI power off failed for node %(node_id)s with the " + "following error: %(error)s") try: ipmicmd = ipmi_command.Command(bmc=driver_info['address'], userid=driver_info['username'], @@ -171,7 +170,7 @@ def _power_off(driver_info): wait = CONF.ipmi.retry_timeout ret = ipmicmd.set_power('off', wait) except pyghmi_exception.IpmiException as e: - LOG.warning(msg % {'node_id': driver_info['uuid'], 'error': str(e)}) + LOG.warning(msg, {'node_id': driver_info['uuid'], 'error': str(e)}) raise exception.IPMIFailure(cmd=str(e)) state = ret.get('powerstate') @@ -194,8 +193,8 @@ def _reboot(driver_info): from ipmi. """ - msg = _("IPMI power reboot failed for node %(node_id)s with the " - "following error: %(error)s") + msg = _LW("IPMI power reboot failed for node %(node_id)s with the " + "following error: %(error)s") try: ipmicmd = ipmi_command.Command(bmc=driver_info['address'], userid=driver_info['username'], @@ -229,9 +228,9 @@ def _power_status(driver_info): password=driver_info['password']) ret = ipmicmd.get_power() except pyghmi_exception.IpmiException as e: - LOG.warning(_("IPMI get power state failed for node %(node_id)s " - "with the following error: %(error)s") - % {'node_id': driver_info['uuid'], 'error': str(e)}) + LOG.warning(_LW("IPMI get power state failed for node %(node_id)s " + "with the following error: %(error)s"), + {'node_id': driver_info['uuid'], 'error': str(e)}) raise exception.IPMIFailure(cmd=str(e)) state = ret.get('powerstate') @@ -243,9 +242,9 @@ def _power_status(driver_info): # NOTE(linggao): Do not throw an exception here because it might # return other valid values. It is up to the caller to decide # what to do. - LOG.warning(_("IPMI get power state for node %(node_id)s returns the " - "following details: %(detail)s") - % {'node_id': driver_info['uuid'], 'detail': ret}) + LOG.warning(_LW("IPMI get power state for node %(node_id)s returns the" + " following details: %(detail)s"), + {'node_id': driver_info['uuid'], 'detail': ret}) return states.ERROR diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index c7e878da0..9333ac51e 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -41,8 +41,9 @@ from oslo.utils import excutils from ironic.common import boot_devices from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -53,8 +54,6 @@ from ironic.openstack.common import loopingcall from ironic.openstack.common import processutils -_LW = i18n._LW - CONF = cfg.CONF CONF.import_opt('retry_timeout', 'ironic.drivers.modules.ipminative', @@ -400,8 +399,8 @@ def _set_and_wait(target_state, driver_info): processutils.ProcessExecutionError, exception.IPMIFailure): # Log failures but keep trying - LOG.warning(_("IPMI power %(state)s failed for node %(node)s."), - {'state': state_name, 'node': driver_info['uuid']}) + LOG.warning(_LW("IPMI power %(state)s failed for node %(node)s."), + {'state': state_name, 'node': driver_info['uuid']}) finally: mutable['iter'] += 1 @@ -411,10 +410,10 @@ def _set_and_wait(target_state, driver_info): sleep_time = _sleep_time(mutable['iter']) if (sleep_time + mutable['total_time']) > CONF.ipmi.retry_timeout: # Stop if the next loop would exceed maximum retry_timeout - LOG.error(_('IPMI power %(state)s timed out after ' - '%(tries)s retries on node %(node_id)s.'), - {'state': state_name, 'tries': mutable['iter'], - 'node_id': driver_info['uuid']}) + LOG.error(_LE('IPMI power %(state)s timed out after ' + '%(tries)s retries on node %(node_id)s.'), + {'state': state_name, 'tries': mutable['iter'], + 'node_id': driver_info['uuid']}) mutable['power'] = states.ERROR raise loopingcall.LoopingCallDone() else: @@ -465,9 +464,9 @@ def _power_status(driver_info): out_err = _exec_ipmitool(driver_info, cmd) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.warning(_("IPMI power status failed for node %(node_id)s with " - "error: %(error)s.") - % {'node_id': driver_info['uuid'], 'error': e}) + LOG.warning(_LW("IPMI power status failed for node %(node_id)s with " + "error: %(error)s."), + {'node_id': driver_info['uuid'], 'error': e}) raise exception.IPMIFailure(cmd=cmd) if out_err[0] == "Chassis Power is on\n": @@ -816,7 +815,7 @@ class VendorPassthru(base.VendorInterface): ' %(stderr)s', {'stdout': out, 'stderr': err}) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.exception(_('IPMI "raw bytes" failed for node %(node_id)s ' + LOG.exception(_LE('IPMI "raw bytes" failed for node %(node_id)s ' 'with error: %(error)s.'), {'node_id': node_uuid, 'error': e}) raise exception.IPMIFailure(cmd=cmd) @@ -850,7 +849,7 @@ class VendorPassthru(base.VendorInterface): ' %(stderr)s', {'stdout': out, 'stderr': err}) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.exception(_('IPMI "bmc reset" failed for node %(node_id)s ' + LOG.exception(_LE('IPMI "bmc reset" failed for node %(node_id)s ' 'with error: %(error)s.'), {'node_id': node_uuid, 'error': e}) raise exception.IPMIFailure(cmd=cmd) diff --git a/ironic/drivers/modules/iscsi_deploy.py b/ironic/drivers/modules/iscsi_deploy.py index 620de6859..0ecf9d74b 100644 --- a/ironic/drivers/modules/iscsi_deploy.py +++ b/ironic/drivers/modules/iscsi_deploy.py @@ -18,8 +18,9 @@ import os from oslo.config import cfg from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LI from ironic.common import image_service as service from ironic.common import keystone from ironic.common import states @@ -34,9 +35,6 @@ from ironic.openstack.common import strutils LOG = logging.getLogger(__name__) -_LE = i18n._LE -_LI = i18n._LI - # NOTE(rameshg87): This file now registers some of opts in pxe group. # This is acceptable for now as a future refactoring into # separate boot and deploy interfaces is planned, and moving config diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 73eff77df..87565e11b 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -24,8 +24,10 @@ from oslo.config import cfg from ironic.common import dhcp_factory from ironic.common import exception -from ironic.common import i18n 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 image_service as service from ironic.common import paths from ironic.common import pxe_utils @@ -41,9 +43,6 @@ from ironic.openstack.common import fileutils from ironic.openstack.common import log as logging -_LE = i18n._LE -_LW = i18n._LW - pxe_opts = [ cfg.StrOpt('pxe_config_template', default=paths.basedir_def( @@ -88,9 +87,6 @@ pxe_opts = [ LOG = logging.getLogger(__name__) -_LE = i18n._LE -_LI = i18n._LI - CONF = cfg.CONF CONF.register_opts(pxe_opts, group='pxe') CONF.import_opt('use_ipv6', 'ironic.netconf') diff --git a/ironic/drivers/modules/seamicro.py b/ironic/drivers/modules/seamicro.py index 5628bec72..b288ce0ae 100644 --- a/ironic/drivers/modules/seamicro.py +++ b/ironic/drivers/modules/seamicro.py @@ -24,8 +24,9 @@ from oslo.utils import importutils from ironic.common import boot_devices from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base @@ -46,8 +47,6 @@ opts = [ help='Seconds to wait for power action to be completed') ] -_LE = i18n._LE - CONF = cfg.CONF opt_group = cfg.OptGroup(name='seamicro', title='Options for the seamicro power driver') @@ -165,7 +164,7 @@ def _get_power_status(node): except seamicro_client_exception.NotFound: raise exception.NodeNotFound(node=node.uuid) except seamicro_client_exception.ClientException as ex: - LOG.error(_("SeaMicro client exception %(msg)s for node %(uuid)s"), + LOG.error(_LE("SeaMicro client exception %(msg)s for node %(uuid)s"), {'msg': ex.message, 'uuid': node.uuid}) raise exception.ServiceUnavailable(message=ex.message) @@ -201,7 +200,7 @@ def _power_on(node, timeout=None): retries[0] += 1 server.power_on() except seamicro_client_exception.ClientException: - LOG.warning(_("Power-on failed for node %s."), + LOG.warning(_LW("Power-on failed for node %s."), node.uuid) timer = loopingcall.FixedIntervalLoopingCall(_wait_for_power_on, @@ -241,7 +240,7 @@ def _power_off(node, timeout=None): retries[0] += 1 server.power_off() except seamicro_client_exception.ClientException: - LOG.warning(_("Power-off failed for node %s."), + LOG.warning(_LW("Power-off failed for node %s."), node.uuid) timer = loopingcall.FixedIntervalLoopingCall(_wait_for_power_off, @@ -281,7 +280,7 @@ def _reboot(node, timeout=None): retries[0] += 1 server.reset() except seamicro_client_exception.ClientException: - LOG.warning(_("Reboot failed for node %s."), + LOG.warning(_LW("Reboot failed for node %s."), node.uuid) timer = loopingcall.FixedIntervalLoopingCall(_wait_for_reboot, @@ -449,7 +448,7 @@ class VendorPassthru(base.VendorInterface): server = server.refresh(5) server.set_untagged_vlan(vlan_id) except seamicro_client_exception.ClientException as ex: - LOG.error(_("SeaMicro client exception: %s"), ex.message) + LOG.error(_LE("SeaMicro client exception: %s"), ex.message) raise exception.VendorPassthruException(message=ex.message) properties = node.properties @@ -485,7 +484,7 @@ class VendorPassthru(base.VendorInterface): server = server.refresh(5) server.attach_volume(volume_id) except seamicro_client_exception.ClientException as ex: - LOG.error(_("SeaMicro client exception: %s"), ex.message) + LOG.error(_LE("SeaMicro client exception: %s"), ex.message) raise exception.VendorPassthruException(message=ex.message) properties = node.properties diff --git a/ironic/drivers/modules/snmp.py b/ironic/drivers/modules/snmp.py index a1d8bd821..09b4069ad 100644 --- a/ironic/drivers/modules/snmp.py +++ b/ironic/drivers/modules/snmp.py @@ -34,8 +34,8 @@ from oslo.config import cfg from oslo.utils import importutils from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LW from ironic.common import states from ironic.conductor import task_manager from ironic.drivers import base @@ -56,8 +56,6 @@ opts = [ help='Seconds to wait for power action to be completed') ] -_LW = i18n._LW - LOG = logging.getLogger(__name__) CONF = cfg.CONF diff --git a/ironic/drivers/modules/ssh.py b/ironic/drivers/modules/ssh.py index ebd2f21c4..69877648d 100644 --- a/ironic/drivers/modules/ssh.py +++ b/ironic/drivers/modules/ssh.py @@ -32,8 +32,9 @@ from oslo.config import cfg from ironic.common import boot_devices from ironic.common import exception -from ironic.common import i18n from ironic.common.i18n import _ +from ironic.common.i18n import _LE +from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -48,9 +49,6 @@ libvirt_opts = [ help='libvirt uri') ] -_LW = i18n._LW -_LE = i18n._LE - CONF = cfg.CONF CONF.register_opts(libvirt_opts, group='ssh') @@ -367,7 +365,7 @@ def _get_power_status(ssh_obj, driver_info): if not power_state: power_state = states.POWER_OFF else: - err_msg = _('Node "%(host)s" with MAC address %(mac)s not found.') + err_msg = _LE('Node "%(host)s" with MAC address %(mac)s not found.') LOG.error(err_msg, {'host': driver_info['host'], 'mac': driver_info['macs']}) diff --git a/ironic/drivers/pxe.py b/ironic/drivers/pxe.py index b6cea5263..bcdb4dc55 100644 --- a/ironic/drivers/pxe.py +++ b/ironic/drivers/pxe.py @@ -107,7 +107,7 @@ class PXEAndSeaMicroDriver(base.BaseDriver): if not importutils.try_import('seamicroclient'): raise exception.DriverLoadError( driver=self.__class__.__name__, - reason="Unable to import seamicroclient library") + reason=_("Unable to import seamicroclient library")) self.power = seamicro.Power() self.deploy = pxe.PXEDeploy() self.management = seamicro.Management() @@ -134,7 +134,7 @@ class PXEAndIBootDriver(base.BaseDriver): if not importutils.try_import('iboot'): raise exception.DriverLoadError( driver=self.__class__.__name__, - reason="Unable to import iboot library") + reason=_("Unable to import iboot library")) self.power = iboot.IBootPower() self.deploy = pxe.PXEDeploy() self.vendor = pxe.VendorPassthru() -- cgit v1.2.1