diff options
author | Anup Navare <anup.d.navare@intel.com> | 2017-03-26 19:01:10 +0000 |
---|---|---|
committer | Anup Navare <anup.d.navare@intel.com> | 2017-05-09 17:15:38 +0000 |
commit | 4c82308ebed809352674959a3892f8b3bac01d1b (patch) | |
tree | dfc32ca0afedc65b39cc290c2ff12df13f1c8708 /ironic/drivers | |
parent | 6f237ecfd9db4eefc5a328de6135a8224f682b79 (diff) | |
download | ironic-4c82308ebed809352674959a3892f8b3bac01d1b.tar.gz |
Remove log translations from ironic/drivers Part-1
Log messages are no longer being translated. This removes the use of
_LE, _LI and _LW translation markers from ironic/drivers.
Change-Id: Ie01c1a6a0e0232dce055767854a5d4385b392510
Partial-Bug: #1674374
Diffstat (limited to 'ironic/drivers')
-rw-r--r-- | ironic/drivers/base.py | 8 | ||||
-rw-r--r-- | ironic/drivers/modules/agent.py | 8 | ||||
-rw-r--r-- | ironic/drivers/modules/agent_base_vendor.py | 45 | ||||
-rw-r--r-- | ironic/drivers/modules/console_utils.py | 16 | ||||
-rw-r--r-- | ironic/drivers/modules/deploy_utils.py | 64 | ||||
-rw-r--r-- | ironic/drivers/modules/image_cache.py | 41 | ||||
-rw-r--r-- | ironic/drivers/modules/inspector.py | 24 | ||||
-rw-r--r-- | ironic/drivers/modules/ipmitool.py | 70 | ||||
-rw-r--r-- | ironic/drivers/modules/iscsi_deploy.py | 13 | ||||
-rw-r--r-- | ironic/drivers/modules/pxe.py | 29 | ||||
-rw-r--r-- | ironic/drivers/modules/snmp.py | 10 | ||||
-rw-r--r-- | ironic/drivers/modules/ssh.py | 19 | ||||
-rw-r--r-- | ironic/drivers/utils.py | 29 |
13 files changed, 179 insertions, 197 deletions
diff --git a/ironic/drivers/base.py b/ironic/drivers/base.py index da17bcf8b..4bf0b68ee 100644 --- a/ironic/drivers/base.py +++ b/ironic/drivers/base.py @@ -29,7 +29,7 @@ from oslo_utils import excutils import six from ironic.common import exception -from ironic.common.i18n import _, _LE, _LW +from ironic.common.i18n import _ from ironic.common import raid from ironic.common import states @@ -409,8 +409,8 @@ class DeployInterface(BaseInterface): :param callback_url: a URL to use to call to the ramdisk. :return: None """ - LOG.warning(_LW('Got heartbeat message from node %(node)s, but ' - 'the driver %(driver)s does not support heartbeating'), + LOG.warning('Got heartbeat message from node %(node)s, but ' + 'the driver %(driver)s does not support heartbeating', {'node': task.node.uuid, 'driver': task.node.driver}) @@ -627,7 +627,7 @@ def _passthru(http_methods, method=None, async=True, driver_passthru=False, metadata[1]['require_exclusive_lock'] = require_exclusive_lock func._vendor_metadata = metadata - passthru_logmessage = _LE('vendor_passthru failed with method %s') + passthru_logmessage = 'vendor_passthru failed with method %s' @six.wraps(func) def passthru_handler(*args, **kwargs): diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py index e07753fef..3356cb859 100644 --- a/ironic/drivers/modules/agent.py +++ b/ironic/drivers/modules/agent.py @@ -21,7 +21,7 @@ import six.moves.urllib_parse as urlparse from ironic.common import dhcp_factory from ironic.common import exception from ironic.common.glance_service import service_utils -from ironic.common.i18n import _, _LI, _LW +from ironic.common.i18n import _ from ironic.common import images from ironic.common import raid from ironic.common import states @@ -81,8 +81,8 @@ def check_image_size(task, image_source): properties = node.properties # skip check if 'memory_mb' is not defined if 'memory_mb' not in properties: - LOG.warning(_LW('Skip the image size check as memory_mb is not ' - 'defined in properties on node %s.'), node.uuid) + LOG.warning('Skip the image size check as memory_mb is not ' + 'defined in properties on node %s.', node.uuid) return image_show = images.image_show(task.context, image_source) @@ -285,7 +285,7 @@ class AgentDeployMixin(agent_base_vendor.AgentDeployMixin): task.node.driver_internal_info = driver_internal_info task.node.save() self.prepare_instance_to_boot(task, root_uuid, efi_sys_uuid) - LOG.info(_LI('Image successfully written to node %s'), node.uuid) + LOG.info('Image successfully written to node %s', node.uuid) LOG.debug('Rebooting node %s to instance', node.uuid) if iwdi: manager_utils.node_set_boot_device(task, 'disk', persistent=True) diff --git a/ironic/drivers/modules/agent_base_vendor.py b/ironic/drivers/modules/agent_base_vendor.py index aa4e444a9..b69f1f55c 100644 --- a/ironic/drivers/modules/agent_base_vendor.py +++ b/ironic/drivers/modules/agent_base_vendor.py @@ -26,7 +26,7 @@ import retrying from ironic.common import boot_devices from ironic.common import exception -from ironic.common.i18n import _, _LE, _LI, _LW +from ironic.common.i18n import _ from ironic.common import states from ironic.conductor import rpcapi from ironic.conductor import utils as manager_utils @@ -458,9 +458,9 @@ class AgentDeployMixin(HeartbeatMixin): # version. Both are operator actions, unlike automated # cleaning. Manual clean steps are not necessarily idempotent # like automated clean steps and can be even longer running. - LOG.info(_LI('During manual cleaning, node %(node)s detected ' - 'a clean version mismatch. Re-executing and ' - 'continuing from current step %(step)s.'), + LOG.info('During manual cleaning, node %(node)s detected ' + 'a clean version mismatch. Re-executing and ' + 'continuing from current step %(step)s.', {'node': node.uuid, 'step': node.clean_step}) driver_internal_info = node.driver_internal_info @@ -469,10 +469,9 @@ class AgentDeployMixin(HeartbeatMixin): node.save() else: # Restart cleaning, agent must have rebooted to new version - LOG.info(_LI('During automated cleaning, node %s detected a ' - 'clean version mismatch. Resetting clean steps ' - 'and rebooting the node.'), - node.uuid) + LOG.info('During automated cleaning, node %s detected a ' + 'clean version mismatch. Resetting clean steps ' + 'and rebooting the node.', node.uuid) try: manager_utils.set_node_cleaning_steps(task) except exception.NodeCleaningFailure: @@ -511,8 +510,8 @@ class AgentDeployMixin(HeartbeatMixin): _cleaning_reboot(task) return - LOG.info(_LI('Agent on node %s returned cleaning command success, ' - 'moving to next clean step'), node.uuid) + LOG.info('Agent on node %s returned cleaning command success, ' + 'moving to next clean step', node.uuid) _notify_conductor_resume_clean(task) else: msg = (_('Agent returned unknown status for clean step %(step)s ' @@ -561,13 +560,12 @@ class AgentDeployMixin(HeartbeatMixin): self._client.power_off(node) _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}) manager_utils.node_power_action(task, states.POWER_OFF) else: # Flush the file system prior to hard rebooting the node @@ -578,9 +576,9 @@ class AgentDeployMixin(HeartbeatMixin): error = _('The version of the IPA ramdisk used in ' 'the deployment do not support the ' 'command "sync"') - LOG.warning(_LW( + LOG.warning( 'Failed to flush the file system prior to hard ' - 'rebooting the node %(node)s. Error: %(error)s'), + 'rebooting the node %(node)s. Error: %(error)s', {'node': node.uuid, 'error': error}) manager_utils.node_power_action(task, states.POWER_OFF) @@ -596,7 +594,7 @@ class AgentDeployMixin(HeartbeatMixin): 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) @METRICS.timer('AgentDeployMixin.prepare_instance_to_boot') def prepare_instance_to_boot(self, task, root_uuid, efi_sys_uuid): @@ -617,8 +615,8 @@ class AgentDeployMixin(HeartbeatMixin): try: task.driver.boot.prepare_instance(task) except Exception as e: - LOG.error(_LE('Deploy failed for instance %(instance)s. ' - 'Error: %(error)s'), + LOG.error('Deploy failed for instance %(instance)s. ' + 'Error: %(error)s', {'instance': node.instance_uuid, 'error': e}) msg = _('Failed to continue agent deployment.') log_and_raise_deployment_error(task, msg) @@ -669,5 +667,4 @@ class AgentDeployMixin(HeartbeatMixin): 'error': e}) log_and_raise_deployment_error(task, msg) - LOG.info(_LI('Local boot successfully configured for node %s'), - node.uuid) + LOG.info('Local boot successfully configured for node %s', node.uuid) diff --git a/ironic/drivers/modules/console_utils.py b/ironic/drivers/modules/console_utils.py index 02c21738c..2b41a2f8f 100644 --- a/ironic/drivers/modules/console_utils.py +++ b/ironic/drivers/modules/console_utils.py @@ -33,7 +33,7 @@ from oslo_utils import netutils import psutil from ironic.common import exception -from ironic.common.i18n import _, _LE, _LW +from ironic.common.i18n import _ from ironic.conf import CONF @@ -107,8 +107,8 @@ def _stop_console(node_uuid): "Reason: %(err)s.") % {'node': node_uuid, 'err': exc}) raise exception.ConsoleError(message=msg) else: - LOG.warning(_LW("Console process for node %s is not running " - "but pid file exists."), node_uuid) + LOG.warning("Console process for node %s is not running " + "but pid file exists.", node_uuid) finally: ironic_utils.unlink_without_raise(_get_console_pid_file(node_uuid)) @@ -241,8 +241,8 @@ def stop_shellinabox_console(node_uuid): try: _stop_console(node_uuid) except exception.NoConsolePid: - LOG.warning(_LW("No console pid found for node %s while trying to " - "stop shellinabox console."), node_uuid) + LOG.warning("No console pid found for node %s while trying to " + "stop shellinabox console.", node_uuid) def get_socat_console_url(port): @@ -310,7 +310,7 @@ def start_socat_console(node_uuid, port, console_cmd): error = _("%(exec_error)s\n" "Command: %(command)s") % {'exec_error': str(e), 'command': ' '.join(args)} - LOG.exception(_LE('Unable to start socat console')) + LOG.exception('Unable to start socat console') raise exception.ConsoleSubprocessFailed(error=error) # NOTE: we need to check if socat fails to start here. @@ -366,5 +366,5 @@ def stop_socat_console(node_uuid): try: _stop_console(node_uuid) except exception.NoConsolePid: - LOG.warning(_LW("No console pid found for node %s while trying to " - "stop socat console."), node_uuid) + LOG.warning("No console pid found for node %s while trying to " + "stop socat console.", node_uuid) diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 23af90b94..133b0355b 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -32,7 +32,7 @@ import six from ironic.common import exception from ironic.common.glance_service import service_utils -from ironic.common.i18n import _, _LE, _LW +from ironic.common.i18n import _ from ironic.common import image_service from ironic.common import keystone from ironic.common import states @@ -72,19 +72,18 @@ def warn_about_unsafe_shred_parameters(): iterations = CONF.deploy.shred_random_overwrite_iterations overwrite_with_zeros = CONF.deploy.shred_final_overwrite_with_zeros if iterations == 0 and overwrite_with_zeros is False: - LOG.warning(_LW('With shred_random_overwrite_iterations set to 0 and ' - 'shred_final_overwrite_with_zeros set to False, disks ' - 'may NOT be shredded at all, unless they support ATA ' - 'Secure Erase. This is a possible SECURITY ISSUE!')) + LOG.warning('With shred_random_overwrite_iterations set to 0 and ' + 'shred_final_overwrite_with_zeros set to False, disks ' + 'may NOT be shredded at all, unless they support ATA ' + 'Secure Erase. This is a possible SECURITY ISSUE!') def warn_about_missing_default_boot_option(): if not CONF.deploy.default_boot_option: - LOG.warning(_LW('The default value of default_boot_option ' - 'configuration will change eventually from ' - '"netboot" to "local". It is recommended to set ' - 'an explicit value for it during the transition ' - 'period')) + LOG.warning('The default value of default_boot_option ' + 'configuration will change eventually from ' + '"netboot" to "local". It is recommended to set ' + 'an explicit value for it during the transition period') warn_about_unsafe_shred_parameters() @@ -170,16 +169,15 @@ def login_iscsi(portal_address, portal_port, target_iqn): processutils.ProcessExecutionError) as e: with excutils.save_and_reraise_exception(): error_occurred = True - LOG.error(_LE("Failed to login to an iSCSI target due to %s"), - e) + LOG.error("Failed to login to an iSCSI target due to %s", e) finally: if error_occurred: try: logout_iscsi(portal_address, portal_port, target_iqn) delete_iscsi(portal_address, portal_port, target_iqn) except processutils.ProcessExecutionError as e: - LOG.warning(_LW("An error occurred when trying to cleanup " - "failed ISCSI session error %s"), e) + LOG.warning("An error occurred when trying to cleanup " + "failed ISCSI session error %s", e) def check_file_system_for_iscsi_device(portal_address, @@ -445,13 +443,13 @@ def _iscsi_setup_and_handle_errors(address, port, iqn, lun): yield dev except processutils.ProcessExecutionError as err: with excutils.save_and_reraise_exception(): - 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) + 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) except exception.InstanceDeployFailure as e: with excutils.save_and_reraise_exception(): - LOG.error(_LE("Deploy to address %s failed."), address) + LOG.error("Deploy to address %s failed.", address) LOG.error(e) finally: logout_iscsi(address, port, iqn) @@ -526,8 +524,8 @@ def set_failed_state(task, msg, collect_logs=True): try: task.process_event('fail') except exception.InvalidState: - msg2 = (_LE('Internal error. Node %(node)s in provision state ' - '"%(state)s" could not transition to a failed state.') + msg2 = ('Internal error. Node %(node)s in provision state ' + '"%(state)s" could not transition to a failed state.' % {'node': node.uuid, 'state': node.provision_state}) LOG.exception(msg2) @@ -535,10 +533,10 @@ def set_failed_state(task, msg, collect_logs=True): try: manager_utils.node_power_action(task, states.POWER_OFF) except Exception: - msg2 = (_LE('Node %s failed to power off while handling deploy ' - 'failure. This may be a serious condition. Node ' - 'should be removed from Ironic or put in maintenance ' - 'mode until the problem is resolved.') % node.uuid) + msg2 = ('Node %s failed to power off while handling deploy ' + 'failure. This may be a serious condition. Node ' + 'should be removed from Ironic or put in maintenance ' + 'mode until the problem is resolved.' % node.uuid) LOG.exception(msg2) # NOTE(deva): node_power_action() erases node.last_error # so we need to set it here. @@ -709,9 +707,9 @@ def try_set_boot_device(task, device, persistent=True): with excutils.save_and_reraise_exception() as ctxt: if get_boot_mode_for_deploy(task.node) == 'uefi': ctxt.reraise = False - LOG.warning(_LW("ipmitool is unable to set boot device while " - "the node %s is in UEFI boot mode. Please set " - "the boot device manually."), task.node.uuid) + LOG.warning("ipmitool is unable to set boot device while " + "the node %s is in UEFI boot mode. Please set " + "the boot device manually.", task.node.uuid) def is_secure_boot_requested(node): @@ -1187,11 +1185,11 @@ def build_instance_info_for_deploy(task): image_service.HttpImageService().validate_href(url, secret) except exception.ImageRefValidationFailed as e: with excutils.save_and_reraise_exception(): - LOG.error(_LE("Agent deploy supports only HTTP(S) URLs as " - "instance_info['image_source'] or swift " - "temporary URL. Either the specified URL is not " - "a valid HTTP(S) URL or is not reachable " - "for node %(node)s. Error: %(msg)s"), + LOG.error("Agent deploy supports only HTTP(S) URLs as " + "instance_info['image_source'] or swift " + "temporary URL. Either the specified URL is not " + "a valid HTTP(S) URL or is not reachable " + "for node %(node)s. Error: %(msg)s", {'node': node.uuid, 'msg': e}) node = task.node instance_info = node.instance_info diff --git a/ironic/drivers/modules/image_cache.py b/ironic/drivers/modules/image_cache.py index 11702a5b7..0a5f8723f 100644 --- a/ironic/drivers/modules/image_cache.py +++ b/ironic/drivers/modules/image_cache.py @@ -30,7 +30,6 @@ import six from ironic.common import exception from ironic.common.glance_service import service_utils -from ironic.common.i18n import _LI, _LW from ironic.common import image_service from ironic.common import images from ironic.common import utils @@ -129,9 +128,8 @@ class ImageCache(object): {'href': href}) return - LOG.info(_LI("Master cache miss for image %(href)s, " - "starting download"), - {'href': href}) + LOG.info("Master cache miss for image %(href)s, " + "starting download", {'href': href}) self._download_image( href, master_path, dest_path, ctx=ctx, force_raw=force_raw) @@ -190,11 +188,10 @@ class ImageCache(object): return amount = self._clean_up_ensure_cache_size(survived, amount) if amount is not None and amount > 0: - LOG.warning( - _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}) + LOG.warning("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}) def _clean_up_too_old(self, listing, amount): """Clean up stage 1: drop images that are older than TTL. @@ -218,8 +215,8 @@ class ImageCache(object): try: os.unlink(file_name) except EnvironmentError as exc: - LOG.warning(_LW("Unable to delete file %(name)s from " - "master image cache: %(exc)s"), + LOG.warning("Unable to delete file %(name)s from " + "master image cache: %(exc)s", {'name': file_name, 'exc': exc}) else: if amount is not None: @@ -257,8 +254,8 @@ class ImageCache(object): try: os.unlink(file_name) except EnvironmentError as exc: - LOG.warning(_LW("Unable to delete file %(name)s from " - "master image cache: %(exc)s"), + LOG.warning("Unable to delete file %(name)s from " + "master image cache: %(exc)s", {'name': file_name, 'exc': exc}) else: total_size -= stat.st_size @@ -266,9 +263,9 @@ class ImageCache(object): amount -= stat.st_size if total_size > self._cache_size: - LOG.info(_LI("After cleaning up cache dir %(dir)s " - "cache size %(actual)d is still larger than " - "threshold %(expected)d"), + LOG.info("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) if amount is not None else 0 @@ -392,17 +389,17 @@ def _delete_master_path_if_stale(master_path, href, ctx): if not img_mtime: # This means that href is not a glance image and doesn't have an # updated_at attribute - LOG.warning(_LW("Image service couldn't determine last " - "modification time of %(href)s, considering " - "cached image up to date."), {'href': href}) + LOG.warning("Image service couldn't determine last " + "modification time of %(href)s, considering " + "cached image up to date.", {'href': href}) return True master_mtime = utils.unix_file_modification_datetime(master_path) if img_mtime <= master_mtime: return True # Delete image from cache as it is outdated - LOG.info(_LI('Image %(href)s was last modified at %(remote_time)s. ' - 'Deleting the cached copy "%(cached_file)s since it was ' - 'last modified at %(local_time)s and may be outdated.'), + LOG.info('Image %(href)s was last modified at %(remote_time)s. ' + 'Deleting the cached copy "%(cached_file)s since it was ' + 'last modified at %(local_time)s and may be outdated.', {'href': href, 'remote_time': img_mtime, 'local_time': master_mtime, 'cached_file': master_path}) diff --git a/ironic/drivers/modules/inspector.py b/ironic/drivers/modules/inspector.py index 0fe60336f..49092dc39 100644 --- a/ironic/drivers/modules/inspector.py +++ b/ironic/drivers/modules/inspector.py @@ -21,7 +21,7 @@ from oslo_log import log as logging from oslo_utils import importutils from ironic.common import exception -from ironic.common.i18n import _, _LE, _LI +from ironic.common.i18n import _ from ironic.common import keystone from ironic.common import states from ironic.conductor import task_manager @@ -70,9 +70,9 @@ class Inspector(base.InspectInterface): if CONF.inspector.enabled: return cls() else: - LOG.info(_LI("Inspection via ironic-inspector is disabled in " - "configuration for driver %s. To enable, change " - "[inspector] enabled = True."), driver_name) + LOG.info("Inspection via ironic-inspector is disabled in " + "configuration for driver %s. To enable, change " + "[inspector] enabled = True.", driver_name) def __init__(self): if not client: @@ -138,8 +138,8 @@ def _start_inspection(node_uuid, context): try: _get_client().introspect(node_uuid) except Exception as exc: - LOG.exception(_LE('Exception during contacting ironic-inspector ' - 'for inspection of node %(node)s: %(err)s'), + LOG.exception('Exception during contacting ironic-inspector ' + 'for inspection of node %(node)s: %(err)s', {'node': node_uuid, 'err': exc}) # NOTE(dtantsur): if acquire fails our last option is to rely on # timeout @@ -149,7 +149,7 @@ def _start_inspection(node_uuid, context): task.node.last_error = _('Failed to start inspection: %s') % exc task.process_event('fail') else: - LOG.info(_LI('Node %s was sent to inspection to ironic-inspector'), + LOG.info('Node %s was sent to inspection to ironic-inspector', node_uuid) @@ -169,8 +169,8 @@ def _check_status(task): except Exception: # NOTE(dtantsur): get_status should not normally raise # let's assume it's a transient failure and retry later - LOG.exception(_LE('Unexpected exception while getting ' - 'inspection status for node %s, will retry later'), + LOG.exception('Unexpected exception while getting ' + 'inspection status for node %s, will retry later', node.uuid) return @@ -185,13 +185,11 @@ def _check_status(task): node = task.node if error: - LOG.error(_LE('Inspection failed for node %(uuid)s ' - 'with error: %(err)s'), + LOG.error('Inspection failed for node %(uuid)s with error: %(err)s', {'uuid': node.uuid, 'err': error}) node.last_error = (_('ironic-inspector inspection failed: %s') % error) task.process_event('fail') elif finished: - LOG.info(_LI('Inspection finished successfully for node %s'), - node.uuid) + LOG.info('Inspection finished successfully for node %s', node.uuid) task.process_event('done') diff --git a/ironic/drivers/modules/ipmitool.py b/ironic/drivers/modules/ipmitool.py index d180e22c4..65606894c 100644 --- a/ironic/drivers/modules/ipmitool.py +++ b/ironic/drivers/modules/ipmitool.py @@ -47,7 +47,7 @@ import six from ironic.common import boot_devices from ironic.common import exception -from ironic.common.i18n import _, _LE, _LI, _LW +from ironic.common.i18n import _ from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -163,11 +163,11 @@ def _check_option_support(options): subprocess.check_call(cmd, stdout=nullfile, stderr=nullfile) except subprocess.CalledProcessError: - LOG.info(_LI("Option %(opt)s is not supported by ipmitool"), + LOG.info("Option %(opt)s is not supported by ipmitool", {'opt': opt}) _is_option_supported(opt, False) else: - LOG.info(_LI("Option %(opt)s is supported by ipmitool"), + LOG.info("Option %(opt)s is supported by ipmitool", {'opt': opt}) _is_option_supported(opt, True) @@ -276,11 +276,11 @@ def _parse_driver_info(node): force_boot_device = info.get('ipmi_force_boot_device', False) if not username: - LOG.warning(_LW('ipmi_username is not defined or empty for node %s: ' - 'NULL user will be utilized.'), node.uuid) + LOG.warning('ipmi_username is not defined or empty for node %s: ' + 'NULL user will be utilized.', node.uuid) if not password: - LOG.warning(_LW('ipmi_password is not defined or empty for node %s: ' - 'NULL password will be utilized.'), node.uuid) + LOG.warning('ipmi_password is not defined or empty for node %s: ' + 'NULL password will be utilized.', node.uuid) if protocol_version not in VALID_PROTO_VERSIONS: valid_versions = ', '.join(VALID_PROTO_VERSIONS) @@ -440,19 +440,17 @@ def _exec_ipmitool(driver_info, command, check_exit_code=None): if ((time.time() > end_time) or (num_tries == 0) or not err_list): - LOG.error(_LE('IPMI Error while attempting "%(cmd)s" ' - 'for node %(node)s. Error: %(error)s'), { - 'node': driver_info['uuid'], - 'cmd': e.cmd, 'error': e - }) + LOG.error('IPMI Error while attempting "%(cmd)s" ' + 'for node %(node)s. Error: %(error)s', + {'node': driver_info['uuid'], + 'cmd': e.cmd, 'error': e}) else: ctxt.reraise = False - LOG.warning(_LW('IPMI Error encountered, retrying ' - '"%(cmd)s" for node %(node)s. ' - 'Error: %(error)s'), { - 'node': driver_info['uuid'], - 'cmd': e.cmd, 'error': e - }) + LOG.warning('IPMI Error encountered, retrying ' + '"%(cmd)s" for node %(node)s. ' + 'Error: %(error)s', + {'node': driver_info['uuid'], + 'cmd': e.cmd, 'error': e}) finally: LAST_CMD_TIME[driver_info['address']] = time.time() @@ -515,7 +513,7 @@ def _set_and_wait(power_action, driver_info, timeout=None): processutils.ProcessExecutionError, exception.IPMIFailure): # Log failures but keep trying - LOG.warning(_LW("IPMI power %(state)s failed for node %(node)s."), + LOG.warning("IPMI power %(state)s failed for node %(node)s.", {'state': cmd_name, 'node': driver_info['uuid']}) finally: mutable['iter'] += 1 @@ -526,8 +524,8 @@ def _set_and_wait(power_action, driver_info, timeout=None): sleep_time = _sleep_time(mutable['iter']) if (sleep_time + mutable['total_time']) > retry_timeout: # Stop if the next loop would exceed maximum retry_timeout - LOG.error(_LE('IPMI power %(state)s timed out after ' - '%(tries)s retries on node %(node_id)s.'), + LOG.error('IPMI power %(state)s timed out after ' + '%(tries)s retries on node %(node_id)s.', {'state': cmd_name, 'tries': mutable['iter'], 'node_id': driver_info['uuid']}) mutable['power'] = states.ERROR @@ -597,8 +595,8 @@ def _power_status(driver_info): out_err = _exec_ipmitool(driver_info, cmd) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.warning(_LW("IPMI power status failed for node %(node_id)s with " - "error: %(error)s."), + LOG.warning("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) @@ -708,8 +706,8 @@ def send_raw(task, raw_bytes): ' %(stderr)s', {'stdout': out, 'stderr': err}) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.exception(_LE('IPMI "raw bytes" failed for node %(node_id)s ' - 'with error: %(error)s.'), + LOG.exception('IPMI "raw bytes" failed for node %(node_id)s ' + 'with error: %(error)s.', {'node_id': node_uuid, 'error': e}) raise exception.IPMIFailure(cmd=cmd) @@ -739,8 +737,8 @@ def dump_sdr(task, file_path): ' %(stderr)s', {'stdout': out, 'stderr': err}) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.exception(_LE('IPMI "sdr dump" failed for node %(node_id)s ' - 'with error: %(error)s.'), + LOG.exception('IPMI "sdr dump" failed for node %(node_id)s ' + 'with error: %(error)s.', {'node_id': node_uuid, 'error': e}) raise exception.IPMIFailure(cmd=cmd) @@ -1013,9 +1011,9 @@ class IPMIManagement(base.ManagementInterface): out, err = _exec_ipmitool(driver_info, cmd) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.warning(_LW('IPMI set boot device failed for node %(node)s ' - 'when executing "ipmitool %(cmd)s". ' - 'Error: %(error)s'), + LOG.warning('IPMI set boot device failed for node %(node)s ' + 'when executing "ipmitool %(cmd)s". ' + 'Error: %(error)s', {'node': driver_info['uuid'], 'cmd': cmd, 'error': e}) raise exception.IPMIFailure(cmd=cmd) @@ -1057,9 +1055,9 @@ class IPMIManagement(base.ManagementInterface): out, err = _exec_ipmitool(driver_info, cmd) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.warning(_LW('IPMI get boot device failed for node %(node)s ' - 'when executing "ipmitool %(cmd)s". ' - 'Error: %(error)s'), + LOG.warning('IPMI get boot device failed for node %(node)s ' + 'when executing "ipmitool %(cmd)s". ' + 'Error: %(error)s', {'node': driver_info['uuid'], 'cmd': cmd, 'error': e}) raise exception.IPMIFailure(cmd=cmd) @@ -1123,7 +1121,7 @@ class IPMIManagement(base.ManagementInterface): _exec_ipmitool(driver_info, "power diag") except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as err: - LOG.error(_LE('Inject NMI failed for node %(node)s: %(err)s.'), + LOG.error('Inject NMI failed for node %(node)s: %(err)s.', {'node': task.node.uuid, 'err': err}) raise exception.IPMIFailure(cmd="power diag") @@ -1188,8 +1186,8 @@ class VendorPassthru(base.VendorInterface): ' %(stderr)s', {'stdout': out, 'stderr': err}) except (exception.PasswordFileFailedToCreate, processutils.ProcessExecutionError) as e: - LOG.exception(_LE('IPMI "bmc reset" failed for node %(node_id)s ' - 'with error: %(error)s.'), + LOG.exception('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 760f6820c..ddf6dd041 100644 --- a/ironic/drivers/modules/iscsi_deploy.py +++ b/ironic/drivers/modules/iscsi_deploy.py @@ -25,7 +25,7 @@ from six.moves.urllib import parse from ironic.common import dhcp_factory from ironic.common import exception -from ironic.common.i18n import _, _LE +from ironic.common.i18n import _ from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -250,14 +250,13 @@ def continue_deploy(task, **kwargs): uuid_dict_returned = deploy_utils.deploy_partition_image(**params) except exception.IronicException as e: with excutils.save_and_reraise_exception(): - LOG.error(_LE('Deploy of instance %(instance)s on node %(node)s ' - 'failed: %(error)s'), - {'instance': node.instance_uuid, 'node': node.uuid, - 'error': e}) + LOG.error('Deploy of instance %(instance)s on node %(node)s ' + 'failed: %(error)s', {'instance': node.instance_uuid, + 'node': node.uuid, 'error': e}) _fail_deploy(task, e, raise_exception=False) except Exception as e: - LOG.exception(_LE('Deploy of instance %(instance)s on node %(node)s ' - 'failed with exception'), + LOG.exception('Deploy of instance %(instance)s on node %(node)s ' + 'failed with exception', {'instance': node.instance_uuid, 'node': node.uuid}) _fail_deploy(task, e) diff --git a/ironic/drivers/modules/pxe.py b/ironic/drivers/modules/pxe.py index 5a3af41b5..4524352dd 100644 --- a/ironic/drivers/modules/pxe.py +++ b/ironic/drivers/modules/pxe.py @@ -26,7 +26,7 @@ from ironic.common import boot_devices from ironic.common import dhcp_factory from ironic.common import exception from ironic.common.glance_service import service_utils -from ironic.common.i18n import _, _LW +from ironic.common.i18n import _ from ironic.common import image_service as service from ironic.common import images from ironic.common import pxe_utils @@ -444,8 +444,8 @@ class PXEBoot(base.BootInterface): try: images_info = _get_deploy_image_info(node) except exception.MissingParameterValue as e: - LOG.warning(_LW('Could not get deploy image info ' - 'to clean up images for node %(node)s: %(err)s'), + LOG.warning('Could not get deploy image info ' + 'to clean up images for node %(node)s: %(err)s', {'node': node.uuid, 'err': e}) else: _clean_up_pxe_env(task, images_info) @@ -485,18 +485,15 @@ class PXEBoot(base.BootInterface): ] except KeyError: if not iwdi: - LOG.warning( - _LW("The UUID for the root partition can't be " - "found, unable to switch the pxe config from " - "deployment mode to service (boot) mode for " - "node %(node)s"), {"node": task.node.uuid}) + LOG.warning("The UUID for the root partition can't be " + "found, unable to switch the pxe config from " + "deployment mode to service (boot) mode for " + "node %(node)s", {"node": task.node.uuid}) else: - LOG.warning( - _LW("The disk id for the whole disk image can't " - "be found, unable to switch the pxe config " - "from deployment mode to service (boot) mode " - "for node %(node)s"), - {"node": task.node.uuid}) + LOG.warning("The disk id for the whole disk image can't " + "be found, unable to switch the pxe config " + "from deployment mode to service (boot) mode " + "for node %(node)s", {"node": task.node.uuid}) else: _build_service_pxe_config(task, instance_image_info, root_uuid_or_disk_id) @@ -529,8 +526,8 @@ class PXEBoot(base.BootInterface): try: images_info = _get_instance_image_info(node, task.context) except exception.MissingParameterValue as e: - LOG.warning(_LW('Could not get instance image info ' - 'to clean up images for node %(node)s: %(err)s'), + LOG.warning('Could not get instance image info ' + 'to clean up images for node %(node)s: %(err)s', {'node': node.uuid, 'err': e}) else: _clean_up_pxe_env(task, images_info) diff --git a/ironic/drivers/modules/snmp.py b/ironic/drivers/modules/snmp.py index 63bbc58f9..5b9ffb651 100644 --- a/ironic/drivers/modules/snmp.py +++ b/ironic/drivers/modules/snmp.py @@ -32,7 +32,7 @@ from oslo_utils import importutils import six from ironic.common import exception -from ironic.common.i18n import _, _LW +from ironic.common.i18n import _ from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -377,8 +377,8 @@ class SNMPDriverSimple(SNMPDriverBase): elif state == self.value_power_off: power_state = states.POWER_OFF else: - LOG.warning(_LW("SNMP PDU %(addr)s outlet %(outlet)s: " - "unrecognised power state %(state)s."), + LOG.warning("SNMP PDU %(addr)s outlet %(outlet)s: " + "unrecognised power state %(state)s.", {'addr': self.snmp_info['address'], 'outlet': self.snmp_info['outlet'], 'state': state}) @@ -543,8 +543,8 @@ class SNMPDriverEatonPower(SNMPDriverBase): elif state in (self.status_off, self.status_pending_on): power_state = states.POWER_OFF else: - LOG.warning(_LW("Eaton Power SNMP PDU %(addr)s outlet %(outlet)s: " - "unrecognised power state %(state)s."), + LOG.warning("Eaton Power SNMP PDU %(addr)s outlet %(outlet)s: " + "unrecognised power state %(state)s.", {'addr': self.snmp_info['address'], 'outlet': self.snmp_info['outlet'], 'state': state}) diff --git a/ironic/drivers/modules/ssh.py b/ironic/drivers/modules/ssh.py index 9c5c719c7..5b4aa0627 100644 --- a/ironic/drivers/modules/ssh.py +++ b/ironic/drivers/modules/ssh.py @@ -39,7 +39,7 @@ import retrying from ironic.common import boot_devices from ironic.common import exception -from ironic.common.i18n import _, _LE, _LW +from ironic.common.i18n import _ from ironic.common import states from ironic.common import utils from ironic.conductor import task_manager @@ -343,7 +343,7 @@ def _ssh_execute(ssh_obj, cmd_to_exec): output_list = processutils.ssh_execute(ssh_obj, cmd_to_exec)[0].split('\n') except Exception as e: - LOG.error(_LE("Cannot execute SSH cmd %(cmd)s. Reason: %(err)s."), + LOG.error("Cannot execute SSH cmd %(cmd)s. Reason: %(err)s.", {'cmd': cmd_to_exec, 'err': e}) raise exception.SSHCommandFailed(cmd=cmd_to_exec) @@ -773,11 +773,10 @@ class SSHManagement(base.ManagementInterface): _set_boot_device(ssh_obj, driver_info, boot_device_map[device]) except NotImplementedError: with excutils.save_and_reraise_exception(): - LOG.error(_LE("Failed to set boot device for node %(node)s, " - "virt_type %(vtype)s does not support this " - "operation"), - {'node': node.uuid, - 'vtype': driver_info['virt_type']}) + LOG.error("Failed to set boot device for node %(node)s, " + "virt_type %(vtype)s does not support this " + "operation", {'node': node.uuid, + 'vtype': driver_info['virt_type']}) def get_boot_device(self, task): """Get the current boot device for the task's node. @@ -809,9 +808,9 @@ class SSHManagement(base.ManagementInterface): try: response['boot_device'] = _get_boot_device(ssh_obj, driver_info) except NotImplementedError: - LOG.warning(_LW("Failed to get boot device for node %(node)s, " - "virt_type %(vtype)s does not support this " - "operation"), + LOG.warning("Failed to get boot device for node %(node)s, " + "virt_type %(vtype)s does not support this " + "operation", {'node': node.uuid, 'vtype': driver_info['virt_type']}) return response diff --git a/ironic/drivers/utils.py b/ironic/drivers/utils.py index fe1a1c5f2..65902bf03 100644 --- a/ironic/drivers/utils.py +++ b/ironic/drivers/utils.py @@ -22,7 +22,7 @@ from oslo_utils import timeutils import six from ironic.common import exception -from ironic.common.i18n import _, _LE, _LW +from ironic.common.i18n import _ from ironic.common import swift from ironic.conductor import utils from ironic.drivers import base @@ -152,8 +152,8 @@ def get_node_capability(node, capability): if parts[0].strip() == capability: return parts[1].strip() else: - LOG.warning(_LW("Ignoring malformed capability '%s'. " - "Format should be 'key:val'."), node_capability) + LOG.warning("Ignoring malformed capability '%s'. " + "Format should be 'key:val'.", node_capability) def add_node_capability(task, capability, value): @@ -332,30 +332,29 @@ def collect_ramdisk_logs(node): try: result = client.collect_system_logs(node) except exception.IronicException as e: - LOG.error(_LE('Failed to invoke collect_system_logs agent command ' - 'for node %(node)s. Error: %(error)s'), + LOG.error('Failed to invoke collect_system_logs agent command ' + 'for node %(node)s. Error: %(error)s', {'node': node.uuid, 'error': e}) return error = result.get('faultstring') if error is not None: - LOG.error(_LE('Failed to collect logs from the node %(node)s ' - 'deployment. Error: %(error)s'), + LOG.error('Failed to collect logs from the node %(node)s ' + 'deployment. Error: %(error)s', {'node': node.uuid, 'error': error}) return try: store_ramdisk_logs(node, result['command_result']['system_logs']) except exception.SwiftOperationError as e: - LOG.error(_LE('Failed to store the logs from the node %(node)s ' - 'deployment in Swift. Error: %(error)s'), + LOG.error('Failed to store the logs from the node %(node)s ' + 'deployment in Swift. Error: %(error)s', {'node': node.uuid, 'error': e}) except EnvironmentError as e: - LOG.exception(_LE('Failed to store the logs from the node %(node)s ' - 'deployment due a file-system related error. ' - 'Error: %(error)s'), - {'node': node.uuid, 'error': e}) + LOG.exception('Failed to store the logs from the node %(node)s ' + 'deployment due a file-system related error. ' + 'Error: %(error)s', {'node': node.uuid, 'error': e}) except Exception as e: - LOG.exception(_LE('Unknown error when storing logs from the node ' - '%(node)s deployment. Error: %(error)s'), + LOG.exception('Unknown error when storing logs from the node ' + '%(node)s deployment. Error: %(error)s', {'node': node.uuid, 'error': e}) |