Merge "Remove logging translation calls from ironic.common"

This commit is contained in:
Jenkins 2017-05-16 11:20:22 +00:00 committed by Gerrit Code Review
commit 7eef50e738
9 changed files with 83 additions and 90 deletions

View File

@ -20,7 +20,7 @@ from oslo_log import log
from stevedore import dispatch
from ironic.common import exception
from ironic.common.i18n import _, _LI, _LW
from ironic.common.i18n import _
from ironic.conf import CONF
from ironic.drivers import base as driver_base
from ironic.drivers import fake_hardware
@ -64,8 +64,8 @@ def build_driver_for_task(task, driver_name=None):
# storage) set. However, there was a small window
# where this was possible so instead of breaking those
# users totally, we'll spam them with warnings instead.
LOG.warning(_LW('%s They will be ignored. To avoid this warning, '
'please set them to None.'), e)
LOG.warning('%s They will be ignored. To avoid this warning, '
'please set them to None.', e)
bare_driver = driver_base.BareDriver()
_attach_interfaces_to_driver(bare_driver, node, driver_or_hw_type)
@ -433,7 +433,7 @@ class BaseDriverFactory(object):
# without duplicates
_enabled_driver_list = None
# Template for logging loaded drivers
_logging_template = _LI("Loaded the following drivers: %s")
_logging_template = "Loaded the following drivers: %s"
def __init__(self):
if not self.__class__._extension_manager:
@ -465,19 +465,18 @@ class BaseDriverFactory(object):
cls._enabled_driver_list = []
for item, cnt in counter:
if not item:
LOG.warning(
_LW('An empty driver was specified in the "%s" '
'configuration option and will be ignored. Please '
'fix your ironic.conf file to avoid this warning '
'message.'), cls._enabled_driver_list_config_option)
LOG.warning('An empty driver was specified in the "%s" '
'configuration option and will be ignored. Please '
'fix your ironic.conf file to avoid this warning '
'message.', cls._enabled_driver_list_config_option)
continue
if cnt > 1:
duplicated_drivers.append(item)
cls._enabled_driver_list.append(item)
if duplicated_drivers:
LOG.warning(_LW('The driver(s) "%s" is/are duplicated in the '
'list of enabled_drivers. Please check your '
'configuration file.'),
LOG.warning('The driver(s) "%s" is/are duplicated in the '
'list of enabled_drivers. Please check your '
'configuration file.',
', '.join(duplicated_drivers))
# NOTE(deva): Drivers raise "DriverLoadError" if they are unable to be
@ -536,8 +535,8 @@ class BaseDriverFactory(object):
def _warn_if_unsupported(ext):
if not ext.obj.supported:
LOG.warning(_LW('Driver "%s" is UNSUPPORTED. It has been deprecated '
'and may be removed in a future release.'), ext.name)
LOG.warning('Driver "%s" is UNSUPPORTED. It has been deprecated '
'and may be removed in a future release.', ext.name)
class DriverFactory(BaseDriverFactory):
@ -548,7 +547,7 @@ class DriverFactory(BaseDriverFactory):
class HardwareTypesFactory(BaseDriverFactory):
_entrypoint_name = 'ironic.hardware.types'
_enabled_driver_list_config_option = 'enabled_hardware_types'
_logging_template = _LI("Loaded the following hardware types: %s")
_logging_template = "Loaded the following hardware types: %s"
_INTERFACE_LOADERS = {
@ -558,7 +557,7 @@ _INTERFACE_LOADERS = {
'_enabled_driver_list_config_option':
'enabled_%s_interfaces' % name,
'_logging_template':
_LI("Loaded the following %s interfaces: %%s") % name})
"Loaded the following %s interfaces: %%s" % name})
for name in driver_base.ALL_INTERFACES
}

View File

@ -27,7 +27,7 @@ from oslo_serialization import jsonutils
import six
from six.moves import http_client
from ironic.common.i18n import _, _LE
from ironic.common.i18n import _
from ironic.conf import CONF
LOG = logging.getLogger(__name__)
@ -62,16 +62,16 @@ def _ensure_exception_kwargs_serializable(exc_class_name, kwargs):
{'serializer_type': msg, 'e_contents': e,
'e_type': e.__class__.__name__})
if exceptions:
LOG.error(
_LE("One or more arguments passed to the %(exc_class)s "
"constructor as kwargs can not be serialized. The serialized "
"arguments: %(serialized)s. These unserialized kwargs were "
"dropped because of the exceptions encountered during their "
"serialization:\n%(errors)s"),
dict(errors=';\n'.join("%s: %s" % (k, '; '.join(v))
for k, v in exceptions.items()),
exc_class=exc_class_name, serialized=serializable_kwargs)
)
LOG.error("One or more arguments passed to the %(exc_class)s "
"constructor as kwargs can not be serialized. The "
"serialized arguments: %(serialized)s. These "
"unserialized kwargs were dropped because of the "
"exceptions encountered during their "
"serialization:\n%(errors)s",
dict(errors=';\n'.join("%s: %s" % (k, '; '.join(v))
for k, v in exceptions.items()),
exc_class=exc_class_name,
serialized=serializable_kwargs))
# We might be able to actually put the following keys' values into
# format string, but there is no guarantee, drop it just in case.
for k in exceptions:
@ -114,8 +114,8 @@ class IronicException(Exception):
# kwargs doesn't match a variable in self._msg_fmt
# log the issue and the kwargs
prs = ', '.join('%s: %s' % pair for pair in kwargs.items())
LOG.exception(_LE('Exception in string format operation '
'(arguments %s)'), prs)
LOG.exception('Exception in string format operation '
'(arguments %s)', prs)
if CONF.fatal_exception_format_errors:
raise e
else:

View File

@ -29,7 +29,6 @@ import six.moves.urllib.parse as urlparse
from ironic.common import exception
from ironic.common.glance_service import service_utils
from ironic.common.i18n import _LE
LOG = log.getLogger(__name__)
@ -128,9 +127,9 @@ class BaseImageService(object):
except retry_excs as e:
host = self.glance_host
port = self.glance_port
error_msg = _LE("Error contacting glance server "
"'%(host)s:%(port)s' for '%(method)s', attempt"
" %(attempt)s of %(num_attempts)s failed.")
error_msg = ("Error contacting glance server "
"'%(host)s:%(port)s' for '%(method)s', attempt"
" %(attempt)s of %(num_attempts)s failed.")
LOG.exception(error_msg, {'host': host,
'port': port,
'num_attempts': num_attempts,

View File

@ -31,7 +31,7 @@ from oslo_utils import fileutils
from ironic.common import exception
from ironic.common.glance_service import service_utils as glance_utils
from ironic.common.i18n import _, _LE
from ironic.common.i18n import _
from ironic.common import image_service as service
from ironic.common import utils
from ironic.conf import CONF
@ -126,7 +126,7 @@ def create_vfat_image(output_file, files_info=None, parameters=None,
utils.write_to_file(parameters_file, file_contents)
except Exception as e:
LOG.exception(_LE("vfat image creation failed. Error: %s"), e)
LOG.exception("vfat image creation failed. Error: %s", e)
raise exception.ImageCreationFailed(image_type='vfat', error=e)
finally:
@ -196,7 +196,7 @@ def create_isolinux_image_for_bios(output_file, kernel, ramdisk,
try:
_create_root_fs(tmpdir, files_info)
except (OSError, IOError) as e:
LOG.exception(_LE("Creating the filesystem root failed."))
LOG.exception("Creating the filesystem root failed.")
raise exception.ImageCreationFailed(image_type='iso', error=e)
cfg = _generate_cfg(kernel_params,
@ -211,7 +211,7 @@ def create_isolinux_image_for_bios(output_file, kernel, ramdisk,
'-boot-load-size', '4', '-boot-info-table',
'-b', ISOLINUX_BIN, '-o', output_file, tmpdir)
except processutils.ProcessExecutionError as e:
LOG.exception(_LE("Creating ISO image failed."))
LOG.exception("Creating ISO image failed.")
raise exception.ImageCreationFailed(image_type='iso', error=e)
@ -262,7 +262,7 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk,
try:
_create_root_fs(tmpdir, files_info)
except (OSError, IOError) as e:
LOG.exception(_LE("Creating the filesystem root failed."))
LOG.exception("Creating the filesystem root failed.")
raise exception.ImageCreationFailed(image_type='iso', error=e)
finally:
_umount_without_raise(mountdir)
@ -288,7 +288,7 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk,
'-e', e_img_rel_path, '-no-emul-boot',
'-o', output_file, tmpdir)
except processutils.ProcessExecutionError as e:
LOG.exception(_LE("Creating ISO image failed."))
LOG.exception("Creating ISO image failed.")
raise exception.ImageCreationFailed(image_type='iso', error=e)
@ -506,7 +506,7 @@ def _mount_deploy_iso(deploy_iso, mountdir):
try:
utils.mount(deploy_iso, mountdir, '-o', 'loop')
except processutils.ProcessExecutionError as e:
LOG.exception(_LE("mounting the deploy iso failed."))
LOG.exception("mounting the deploy iso failed.")
raise exception.ImageCreationFailed(image_type='iso', error=e)
try:
@ -520,7 +520,7 @@ def _mount_deploy_iso(deploy_iso, mountdir):
grub_rel_path = os.path.relpath(grub_path,
mountdir)
except (OSError, IOError) as e:
LOG.exception(_LE("examining the deploy iso failed."))
LOG.exception("examining the deploy iso failed.")
_umount_without_raise(mountdir)
raise exception.ImageCreationFailed(image_type='iso', error=e)

View File

@ -21,7 +21,7 @@ import six
from six.moves.urllib import parse # for legacy options loading only
from ironic.common import exception
from ironic.common.i18n import _, _LE
from ironic.common.i18n import _
from ironic.conf import auth as ironic_auth
from ironic.conf import CONF
@ -63,7 +63,7 @@ def ks_exceptions(f):
kaexception.MissingRequiredOptions) as e:
raise exception.ConfigInvalid(six.text_type(e))
except Exception as e:
LOG.exception(_LE('Keystone request failed: %(msg)s'),
LOG.exception('Keystone request failed: %(msg)s',
{'msg': six.text_type(e)})
raise exception.KeystoneFailure(six.text_type(e))
return wrapper

View File

@ -16,7 +16,7 @@ from oslo_log import log
from oslo_utils import uuidutils
from ironic.common import exception
from ironic.common.i18n import _, _LE, _LI, _LW
from ironic.common.i18n import _
from ironic.common import keystone
from ironic.conf import CONF
@ -227,9 +227,9 @@ def add_ports_to_network(task, network_uuid, security_groups=None):
port = client.create_port(body)
except neutron_exceptions.NeutronClientException as e:
failures.append(ironic_port.uuid)
LOG.warning(_LW("Could not create neutron port for node's "
"%(node)s port %(ir-port)s on the neutron "
"network %(net)s. %(exc)s"),
LOG.warning("Could not create neutron port for node's "
"%(node)s port %(ir-port)s on the neutron "
"network %(net)s. %(exc)s",
{'net': network_uuid, 'node': node.uuid,
'ir-port': ironic_port.uuid, 'exc': e})
else:
@ -242,13 +242,13 @@ def add_ports_to_network(task, network_uuid, security_groups=None):
"Failed to create neutron ports for any PXE enabled port "
"on node %s.") % node.uuid)
else:
LOG.warning(_LW("Some errors were encountered when updating "
"vif_port_id for node %(node)s on "
"the following ports: %(ports)s."),
LOG.warning("Some errors were encountered when updating "
"vif_port_id for node %(node)s on "
"the following ports: %(ports)s.",
{'node': node.uuid, 'ports': failures})
else:
LOG.info(_LI('Successfully created ports for node %(node_uuid)s in '
'network %(net)s.'),
LOG.info('Successfully created ports for node %(node_uuid)s in '
'network %(net)s.',
{'node_uuid': node.uuid, 'net': network_uuid})
return ports
@ -311,7 +311,7 @@ def remove_neutron_ports(task, params):
LOG.exception(msg)
raise exception.NetworkError(msg)
LOG.info(_LI('Successfully removed node %(node_uuid)s neutron ports.'),
LOG.info('Successfully removed node %(node_uuid)s neutron ports.',
{'node_uuid': node_uuid})
@ -343,10 +343,9 @@ def rollback_ports(task, network_uuid):
remove_ports_from_network(task, network_uuid)
except exception.NetworkError:
# Only log the error
LOG.exception(_LE(
'Failed to rollback port changes for node %(node)s '
'on network %(network)s'), {'node': task.node.uuid,
'network': network_uuid})
LOG.exception('Failed to rollback port changes for '
'node %(node)s on network %(network)s',
{'node': task.node.uuid, 'network': network_uuid})
def validate_network(uuid_or_name, net_type=_('network')):
@ -403,9 +402,9 @@ def validate_port_info(node, port):
"""
if (node.network_interface == 'neutron' and
not port.local_link_connection):
LOG.warning(_LW("The local_link_connection is required for "
"'neutron' network interface and is not present "
"in the nodes %(node)s port %(port)s"),
LOG.warning("The local_link_connection is required for "
"'neutron' network interface and is not present "
"in the nodes %(node)s port %(port)s",
{'node': node.uuid, 'port': port.uuid})
return False

View File

@ -23,7 +23,6 @@ from oslo_log import log
from oslo_policy import policy
from ironic.common import exception
from ironic.common.i18n import _LW
_ENFORCER = None
CONF = cfg.CONF
@ -323,10 +322,9 @@ def enforce(rule, target, creds, do_raise=False, exc=None, *args, **kwargs):
# NOTE(deva): this method is obsoleted by authorize(), but retained for
# backwards compatibility in case it has been used downstream.
# It may be removed in the Pike cycle.
LOG.warning(_LW(
"Deprecation warning: calls to ironic.common.policy.enforce() "
"should be replaced with authorize(). This method may be removed "
"in a future release."))
LOG.warning("Deprecation warning: calls to ironic.common.policy.enforce() "
"should be replaced with authorize(). This method may be "
"removed in a future release.")
if CONF.auth_strategy == 'noauth':
return True
enforcer = get_enforcer()

View File

@ -22,7 +22,6 @@ from oslo_service import service
from oslo_utils import importutils
from ironic.common import context
from ironic.common.i18n import _LE, _LI
from ironic.common import rpc
from ironic.objects import base as objects_base
@ -54,8 +53,8 @@ class RPCService(service.Service):
self.handle_signal()
self.manager.init_host(admin_context)
LOG.info(_LI('Created RPC server for service %(service)s on host '
'%(host)s.'),
LOG.info('Created RPC server for service %(service)s on host '
'%(host)s.',
{'service': self.topic, 'host': self.host})
def stop(self):
@ -63,22 +62,22 @@ class RPCService(service.Service):
self.rpcserver.stop()
self.rpcserver.wait()
except Exception as e:
LOG.exception(_LE('Service error occurred when stopping the '
'RPC server. Error: %s'), e)
LOG.exception('Service error occurred when stopping the '
'RPC server. Error: %s', e)
try:
self.manager.del_host(deregister=self.deregister)
except Exception as e:
LOG.exception(_LE('Service error occurred when cleaning up '
'the RPC manager. Error: %s'), e)
LOG.exception('Service error occurred when cleaning up '
'the RPC manager. Error: %s', e)
super(RPCService, self).stop(graceful=True)
LOG.info(_LI('Stopped RPC server for service %(service)s on host '
'%(host)s.'),
LOG.info('Stopped RPC server for service %(service)s on host '
'%(host)s.',
{'service': self.topic, 'host': self.host})
def _handle_signal(self, signo, frame):
LOG.info(_LI('Got signal SIGUSR1. Not deregistering on next shutdown '
'of service %(service)s on host %(host)s.'),
LOG.info('Got signal SIGUSR1. Not deregistering on next shutdown '
'of service %(service)s on host %(host)s.',
{'service': self.topic, 'host': self.host})
self.deregister = False

View File

@ -37,7 +37,7 @@ import pytz
import six
from ironic.common import exception
from ironic.common.i18n import _, _LE, _LW
from ironic.common.i18n import _
from ironic.conf import CONF
LOG = logging.getLogger(__name__)
@ -312,7 +312,7 @@ def tempdir(**kwargs):
try:
shutil.rmtree(tmpdir)
except OSError as e:
LOG.error(_LE('Could not remove tmpdir: %s'), e)
LOG.error('Could not remove tmpdir: %s', e)
def rmtree_without_raise(path):
@ -320,7 +320,7 @@ def rmtree_without_raise(path):
if os.path.isdir(path):
shutil.rmtree(path)
except OSError as e:
LOG.warning(_LW("Failed to remove dir %(path)s, error: %(e)s"),
LOG.warning("Failed to remove dir %(path)s, error: %(e)s",
{'path': path, 'e': e})
@ -336,10 +336,9 @@ def create_link_without_raise(source, link):
if e.errno == errno.EEXIST:
return
else:
LOG.warning(
_LW("Failed to create symlink from %(source)s to %(link)s"
", error: %(e)s"),
{'source': source, 'link': link, 'e': e})
LOG.warning("Failed to create symlink from "
"%(source)s to %(link)s, error: %(e)s",
{'source': source, 'link': link, 'e': e})
def safe_rstrip(value, chars=None):
@ -351,9 +350,9 @@ def safe_rstrip(value, chars=None):
"""
if not isinstance(value, six.string_types):
LOG.warning(_LW("Failed to remove trailing character. Returning "
"original object. Supplied object is not a string: "
"%s,"), value)
LOG.warning("Failed to remove trailing character. Returning "
"original object. Supplied object is not a string: "
"%s,", value)
return value
return value.rstrip(chars) or value
@ -544,7 +543,7 @@ def warn_about_deprecated_extra_vif_port_id():
global warn_deprecated_extra_vif_port_id
if not warn_deprecated_extra_vif_port_id:
warn_deprecated_extra_vif_port_id = True
LOG.warning(_LW("Attaching VIF to a port/portgroup via "
"extra['vif_port_id'] is deprecated and will not "
"be supported in Pike release. API endpoint "
"v1/nodes/<node>/vifs should be used instead."))
LOG.warning("Attaching VIF to a port/portgroup via "
"extra['vif_port_id'] is deprecated and will not "
"be supported in Pike release. API endpoint "
"v1/nodes/<node>/vifs should be used instead.")