From 70aa08dad88787ff1740a7d021e92977841d2f63 Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: 2024年9月20日 11:12:58 -0700 Subject: [PATCH] Remove use of ironic_lib i18n module We traditionally have not done any translations for IPA, but some of the code carried over from ironic_lib -- as well as a single hardware manager -- were using the i18n wrappers. This removes them from everywhere for consistency. Change-Id: I85a607d7cfb50d605cc62ac8c5e3937802b4d2af --- ironic_python_agent/disk_partitioner.py | 6 +-- ironic_python_agent/disk_utils.py | 26 +++++----- .../nvidia/nvidia_fw_update.py | 49 +++++++++---------- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/ironic_python_agent/disk_partitioner.py b/ironic_python_agent/disk_partitioner.py index a37a8b67b..c8cc6bdc4 100644 --- a/ironic_python_agent/disk_partitioner.py +++ b/ironic_python_agent/disk_partitioner.py @@ -22,7 +22,6 @@ https://opendev.org/openstack/ironic-lib/commit/42fa5d63861ba0f04b9a4f67212173d7 import logging -from ironic_lib.common.i18n import _ from ironic_lib import exception from ironic_lib import utils from oslo_config import cfg @@ -119,6 +118,5 @@ class DiskPartitioner(object): disk_utils.wait_for_disk_to_become_available(self._device) except exception.IronicException as e: raise exception.InstanceDeployFailure( - _('Disk partitioning failed on device %(device)s. ' - 'Error: %(error)s') - % {'device': self._device, 'error': e}) + ('Disk partitioning failed on device %(device)s. ' + 'Error: %(error)s') % {'device': self._device, 'error': e}) diff --git a/ironic_python_agent/disk_utils.py b/ironic_python_agent/disk_utils.py index 662067106..cedd5a1f3 100644 --- a/ironic_python_agent/disk_utils.py +++ b/ironic_python_agent/disk_utils.py @@ -26,7 +26,6 @@ import re import stat import time -from ironic_lib.common.i18n import _ from ironic_lib import exception from ironic_lib import utils from oslo_concurrency import processutils @@ -362,8 +361,8 @@ def is_block_device(dev): time.sleep(1) else: return stat.S_ISBLK(s.st_mode) - msg = _("Unable to stat device %(dev)s after attempting to verify " - "%(attempts)d times.") % {'dev': dev, 'attempts': attempts} + msg = ("Unable to stat device %(dev)s after attempting to verify " + "%(attempts)d times.") % {'dev': dev, 'attempts': attempts} LOG.error(msg) raise exception.InstanceDeployFailure(msg) @@ -607,8 +606,8 @@ def _fix_gpt_structs(device, node_uuid): utils.execute('sgdisk', '-e', device) except (processutils.UnknownArgumentError, processutils.ProcessExecutionError, OSError) as e: - msg = (_('Failed to fix GPT data structures on disk %(disk)s ' - 'for node %(node)s. Error: %(error)s') % + msg = ('Failed to fix GPT data structures on disk %(disk)s ' + 'for node %(node)s. Error: %(error)s' % {'disk': device, 'node': node_uuid, 'error': e}) LOG.error(msg) raise exception.InstanceDeployFailure(msg) @@ -629,8 +628,8 @@ def fix_gpt_partition(device, node_uuid): if disk_is_gpt_partitioned: _fix_gpt_structs(device, node_uuid) except Exception as e: - msg = (_('Failed to fix GPT partition on disk %(disk)s ' - 'for node %(node)s. Error: %(error)s') % + msg = ('Failed to fix GPT partition on disk %(disk)s ' + 'for node %(node)s. Error: %(error)s' % {'disk': device, 'node': node_uuid, 'error': e}) LOG.error(msg) raise exception.InstanceDeployFailure(msg) @@ -789,13 +788,12 @@ def wait_for_disk_to_become_available(device): except tenacity.RetryError: if pids[0]: raise exception.IronicException( - _('Processes with the following PIDs are holding ' - 'device %(device)s: %(pids)s. ' - 'Timed out waiting for completion.') + ('Processes with the following PIDs are holding ' + 'device %(device)s: %(pids)s. ' + 'Timed out waiting for completion.') % {'device': device, 'pids': ', '.join(pids[0])}) else: raise exception.IronicException( - _('Fuser exited with "%(fuser_err)s" while checking ' - 'locks for device %(device)s. Timed out waiting for ' - 'completion.') - % {'device': device, 'fuser_err': stderr[0]}) + ('Fuser exited with "%(fuser_err)s" while checking ' + 'locks for device %(device)s. Timed out waiting for ' + 'completion.') % {'device': device, 'fuser_err': stderr[0]}) diff --git a/ironic_python_agent/hardware_managers/nvidia/nvidia_fw_update.py b/ironic_python_agent/hardware_managers/nvidia/nvidia_fw_update.py index ac8d11e6f..556a278db 100644 --- a/ironic_python_agent/hardware_managers/nvidia/nvidia_fw_update.py +++ b/ironic_python_agent/hardware_managers/nvidia/nvidia_fw_update.py @@ -20,7 +20,6 @@ from urllib import error as urlError from urllib.parse import urlparse from urllib import request -from ironic_lib.common.i18n import _ from ironic_lib.exception import IronicException from oslo_concurrency import processutils from oslo_config import cfg @@ -115,45 +114,45 @@ def check_prereq(): class InvalidFirmwareImageConfig(IronicException): - _msg_fmt = _('Invalid firmware image config: %(error_msg)s') + _msg_fmt = 'Invalid firmware image config: %(error_msg)s' class InvalidFirmwareSettingsConfig(IronicException): - _msg_fmt = _('Invalid firmware settings config: %(error_msg)s') + _msg_fmt = 'Invalid firmware settings config: %(error_msg)s' class MismatchChecksumError(IronicException): - _msg_fmt = _('Mismatch Checksum for the firmware image: %(error_msg)s') + _msg_fmt = 'Mismatch Checksum for the firmware image: %(error_msg)s' class MismatchComponentFlavor(IronicException): - _msg_fmt = _('Mismatch Component Flavor: %(error_msg)s') + _msg_fmt = 'Mismatch Component Flavor: %(error_msg)s' class MismatchFWVersion(IronicException): - _msg_fmt = _('Mismatch Firmware version: %(error_msg)s') + _msg_fmt = 'Mismatch Firmware version: %(error_msg)s' class DuplicateComponentFlavor(IronicException): - _msg_fmt = _('Duplicate Component Flavor for the firmware image: ' - '%(error_msg)s') + _msg_fmt = ('Duplicate Component Flavor for the firmware image: ' + '%(error_msg)s') class DuplicateDeviceID(IronicException): - _msg_fmt = _('Duplicate Device ID for firmware settings: ' - '%(error_msg)s') + _msg_fmt = ('Duplicate Device ID for firmware settings: ' + '%(error_msg)s') class UnSupportedConfigByMstflintPackage(IronicException): - _msg_fmt = _('Unsupported config by mstflint package: %(error_msg)s') + _msg_fmt = 'Unsupported config by mstflint package: %(error_msg)s' class UnSupportedConfigByFW(IronicException): - _msg_fmt = _('Unsupported config by Firmware: %(error_msg)s') + _msg_fmt = 'Unsupported config by Firmware: %(error_msg)s' class InvalidURLScheme(IronicException): - _msg_fmt = _('Invalid URL Scheme: %(error_msg)s') + _msg_fmt = 'Invalid URL Scheme: %(error_msg)s' class NvidiaNicFirmwareOps(object): @@ -454,7 +453,7 @@ class NvidiaNicFirmwareBinary(object): err = 'Firmware URL scheme %s is not supported.' \ 'The supported firmware URL schemes are' \ '(http://, https://, file://)' % url_scheme - raise InvalidURLScheme(error_msg=_(err)) + raise InvalidURLScheme(error_msg=err) def _get_info(self): """Get firmware information from firmware binary image @@ -489,7 +488,7 @@ class NvidiaNicFirmwareBinary(object): err = 'The provided psid %s does not match the image psid %s' % \ (self.psid, image_psid) LOG.error(err) - raise MismatchComponentFlavor(error_msg=_(err)) + raise MismatchComponentFlavor(error_msg=err) def _validate_image_firmware_version(self): """Validate that the provided firmware version same as the version @@ -503,7 +502,7 @@ class NvidiaNicFirmwareBinary(object): err = 'The provided firmware version %s does not match ' \ 'image firmware version %s' % (self.version, image_version) LOG.error(err) - raise MismatchFWVersion(error_msg=_(err)) + raise MismatchFWVersion(error_msg=err) def _validate_image_checksum(self): """Validate the provided checksum with the calculated one of the @@ -517,7 +516,7 @@ class NvidiaNicFirmwareBinary(object): err = 'Mismatch provided checksum %s for image %s' % ( self.checksum, self.url) LOG.error(err) - raise MismatchChecksumError(error_msg=_(err)) + raise MismatchChecksumError(error_msg=err) class NvidiaFirmwareImages(object): @@ -546,7 +545,7 @@ class NvidiaFirmwareImages(object): 'url, checksum, checksumType, componentFlavor, ' \ 'version' % image LOG.error(err) - raise InvalidFirmwareImageConfig(error_msg=_(err)) + raise InvalidFirmwareImageConfig(error_msg=err) def filter_images(self, psids_list): """Filter firmware images according to the system nics PSIDs, @@ -565,7 +564,7 @@ class NvidiaFirmwareImages(object): err = 'Duplicate componentFlavor %s' % \ image['componentFlavor'] LOG.error(err) - raise DuplicateComponentFlavor(error_msg=_(err)) + raise DuplicateComponentFlavor(error_msg=err) else: self.filtered_images_psid_dict[ image.get('componentFlavor')] = image @@ -728,13 +727,13 @@ class NvidiaNicConfig(object): 'please update to the latest mstflint package.' % key LOG.error(err) - raise UnSupportedConfigByMstflintPackage(error_msg=_(err)) + raise UnSupportedConfigByMstflintPackage(error_msg=err) if not self._param_supp_by_fw(key): err = 'Configuraiton %s for device %s is not supported with ' \ 'current fw' % (key, self.nvidia_dev.dev_pci) LOG.error(err) - raise UnSupportedConfigByFW(error_msg=_(err)) + raise UnSupportedConfigByFW(error_msg=err) def set_config(self): """Set device configurations @@ -827,14 +826,14 @@ class NvidiaNicsConfig(object): err = 'duplicate settings for device ID %s ' % \ setting.get('deviceID') LOG.error(err) - raise DuplicateDeviceID(error_msg=_(err)) + raise DuplicateDeviceID(error_msg=err) elif setting.get('deviceID'): LOG.debug('There are no devices with ID %s on the system', setting.get('deviceID')) else: err = 'There is no deviceID provided for this settings' LOG.error(err) - raise InvalidFirmwareSettingsConfig(error_msg=_(err)) + raise InvalidFirmwareSettingsConfig(error_msg=err) def prepare_nvidia_nic_config(self): """Expand the settings map per devices PCI and create a list @@ -909,7 +908,7 @@ def update_nvidia_nic_firmware_image(images): """ if not type(images) is list: err = 'The images must be a list of images, %s' % images - raise InvalidFirmwareImageConfig(error_msg=_(err)) + raise InvalidFirmwareImageConfig(error_msg=err) check_prereq() nvidia_fw_images = NvidiaFirmwareImages(images) nvidia_fw_images.validate_images_schema() @@ -927,7 +926,7 @@ def update_nvidia_nic_firmware_settings(settings): """ if not type(settings) is list: err = 'The settings must be list of settings, %s' % settings - raise InvalidFirmwareSettingsConfig(error_msg=_(err)) + raise InvalidFirmwareSettingsConfig(error_msg=err) check_prereq() nvidia_nics = NvidiaNics() nvidia_nics.discover()

AltStyle によって変換されたページ (->オリジナル) /