Remove log translations

Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Co-Authored-By: lcsong <lcsong@fiberhome.com>

Change-Id: Ic95b5c1c451ce6aced0f44165d2191be1eab3e40
Closes-Bug: 1674560
This commit is contained in:
wanghao 2017-03-21 13:33:07 +08:00
parent 819f075e00
commit 32d9bf7a11
20 changed files with 112 additions and 150 deletions

View File

@ -33,7 +33,6 @@ from mogan.api import expose
from mogan.api import validation
from mogan.common import exception
from mogan.common.i18n import _
from mogan.common.i18n import _LW
from mogan.common import policy
from mogan.common import states
from mogan import network
@ -252,8 +251,8 @@ class FloatingIPController(InstanceControllerBase):
raise wsme.exc.ClientSideError(
msg, status_code=http_client.BAD_REQUEST)
if len(instance_nics) > 1:
LOG.warning(_LW('multiple ports exist, using the first '
'IPv4 fixed_ip: %s'), fixed_address)
LOG.warning('multiple ports exist, using the first '
'IPv4 fixed_ip: %s', fixed_address)
try:
self.network_api.associate_floating_ip(

View File

@ -25,7 +25,6 @@ import six
from six.moves import http_client
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.conf import CONF
LOG = logging.getLogger(__name__)
@ -63,7 +62,7 @@ class MoganException(Exception):
except Exception:
# kwargs doesn't match a variable in self._msg_fmt
# log the issue and the kwargs
LOG.exception(_LE('Exception in string format operation'))
LOG.exception('Exception in string format operation')
for name, value in kwargs.items():
LOG.error("%s: %s" % (name, value))

View File

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

View File

@ -22,7 +22,6 @@ from six.moves.urllib import parse # for legacy options loading only
from mogan.common import exception
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.conf import auth as mogan_auth
from mogan.conf import CONF
@ -64,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

@ -26,7 +26,6 @@ import sys
import wsme
from mogan.common import exception
from mogan.common.i18n import _LW
_ENFORCER = None
CONF = cfg.CONF
@ -308,10 +307,9 @@ def enforce(rule, target, creds, do_raise=False, exc=None, *args, **kwargs):
# NOTE: 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 mogan.common.policy.enforce() "
"should be replaced with authorize(). This method may be removed "
"in a future release."))
LOG.warning("Deprecation warning: calls to mogan.common.policy.enforce() "
"should be replaced with authorize(). This method may be "
"removed in a future release.")
enforcer = get_enforcer()
return enforcer.enforce(rule, target, creds, do_raise=do_raise,

View File

@ -24,8 +24,6 @@ from mogan.api import app
from mogan.common import config
from mogan.common import exception
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common import rpc
from mogan.conf import CONF
from mogan import objects
@ -61,8 +59,8 @@ class RPCService(service.Service):
periodic_interval_max=CONF.periodic_interval,
context=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):
@ -70,17 +68,17 @@ 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()
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})

View File

@ -22,7 +22,6 @@ from oslo_log import log as logging
import six
from mogan.common import exception
from mogan.common.i18n import _LW
from mogan.common import states
LOG = logging.getLogger(__name__)
@ -39,9 +38,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

View File

@ -29,7 +29,7 @@ from sqlalchemy.orm import joinedload
from sqlalchemy.sql.expression import desc
from mogan.common import exception
from mogan.common.i18n import _, _LW
from mogan.common.i18n import _
from mogan.db import api
from mogan.db.sqlalchemy import models
@ -702,8 +702,8 @@ class Connection(api.Connection):
usages[resource].reserved += delta
if unders:
LOG.warning(_LW("Change will make usage less than 0 for the "
"following resources: %s"), unders)
LOG.warning("Change will make usage less than 0 for the "
"following resources: %s", unders)
if overs:
usages = {k: dict(in_use=v.in_use, reserved=v.reserved,
allocated=allocated.get(k, 0))

View File

@ -21,7 +21,6 @@ from oslo_utils import uuidutils
import six
from mogan.common import exception
from mogan.common.i18n import _LI
from mogan.common import states
from mogan.common import utils
from mogan.conf import CONF
@ -199,8 +198,8 @@ class API(object):
if max_net_count < min_count:
raise exception.PortLimitExceeded()
elif max_net_count < max_count:
LOG.info(_LI("max count reduced from %(max_count)d to "
"%(max_net_count)d due to network port quota"),
LOG.info("max count reduced from %(max_count)d to "
"%(max_net_count)d due to network port quota",
{'max_count': max_count,
'max_net_count': max_net_count})
max_count = max_net_count

View File

@ -20,8 +20,6 @@ import sys
from oslo_log import log as logging
from oslo_utils import importutils
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common import utils
LOG = logging.getLogger(__name__)
@ -128,14 +126,14 @@ def load_engine_driver(engine_driver):
"""
if not engine_driver:
LOG.error(_LE("Engine driver option required, but not specified"))
LOG.error("Engine driver option required, but not specified")
sys.exit(1)
LOG.info(_LI("Loading engine driver '%s'"), engine_driver)
LOG.info("Loading engine driver '%s'", engine_driver)
try:
driver = importutils.import_object(
'mogan.engine.baremetal.%s' % engine_driver)
return utils.check_isinstance(driver, BaseEngineDriver)
except ImportError:
LOG.exception(_LE("Unable to load the baremetal driver"))
LOG.exception("Unable to load the baremetal driver")
sys.exit(1)

View File

@ -22,9 +22,6 @@ import six
from mogan.common import exception
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common.i18n import _LW
from mogan.common import ironic
from mogan.common import states
from mogan.conf import CONF
@ -52,7 +49,7 @@ def map_power_state(state):
try:
return _POWER_STATE_MAP[state]
except KeyError:
LOG.warning(_LW("Power state %s not found."), state)
LOG.warning("Power state %s not found.", state)
return states.NOSTATE
@ -110,8 +107,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
properties[prop] = int(node.properties.get(prop, 0))
except (TypeError, ValueError):
LOG.warning(_LW('Node %(uuid)s has a malformed "%(prop)s". '
'It should be an integer.'),
LOG.warning('Node %(uuid)s has a malformed "%(prop)s". '
'It should be an integer.',
{'uuid': node.uuid, 'prop': prop})
properties[prop] = 0
@ -144,8 +141,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
if len(parts) == 2 and parts[0] and parts[1]:
nodes_extra_specs[parts[0].strip()] = parts[1]
else:
LOG.warning(_LW("Ignoring malformed capability '%s'. "
"Format should be 'key:val'."), capability)
LOG.warning("Ignoring malformed capability '%s'. "
"Format should be 'key:val'.", capability)
dic = {
'cpus': cpus,
@ -203,9 +200,9 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
self.ironicclient.call('node.update', node.uuid, patch)
except ironic_exc.BadRequest as e:
LOG.warning(_LW("Failed to remove deploy parameters from node "
"%(node)s when unprovisioning the instance "
"%(instance)s: %(reason)s"),
LOG.warning("Failed to remove deploy parameters from node "
"%(node)s when unprovisioning the instance "
"%(instance)s: %(reason)s",
{'node': node.uuid, 'instance': instance.uuid,
'reason': six.text_type(e)})
@ -317,8 +314,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
ironic_states.ACTIVE)
except Exception as e:
with excutils.save_and_reraise_exception():
msg = (_LE("Failed to request Ironic to provision instance "
"%(inst)s: %(reason)s"),
msg = ("Failed to request Ironic to provision instance "
"%(inst)s: %(reason)s",
{'inst': instance.uuid,
'reason': six.text_type(e)})
LOG.error(msg)
@ -327,12 +324,12 @@ class IronicDriver(base_driver.BaseEngineDriver):
instance)
try:
timer.start(interval=CONF.ironic.api_retry_interval).wait()
LOG.info(_LI('Successfully provisioned Ironic node %s'),
LOG.info('Successfully provisioned Ironic node %s',
node.uuid, instance=instance)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Error deploying instance %(instance)s on "
"baremetal node %(node)s."),
LOG.error("Error deploying instance %(instance)s on "
"baremetal node %(node)s.",
{'instance': instance.uuid,
'node': node_uuid})
@ -402,7 +399,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
node = self._validate_instance_and_node(instance)
except exception.InstanceNotFound:
LOG.warning(_LW("Destroy called on non-existing instance %s."),
LOG.warning("Destroy called on non-existing instance %s.",
instance.uuid)
return
@ -414,7 +411,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
# removed from ironic node.
self._remove_instance_info_from_node(node, instance)
LOG.info(_LI('Successfully unprovisioned Ironic node %s'),
LOG.info('Successfully unprovisioned Ironic node %s',
node.uuid, instance=instance)
def get_available_resources(self):
@ -437,8 +434,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e:
LOG.exception(_LE("Could not get nodes from ironic. Reason: "
"%(detail)s"), {'detail': e.message})
LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s", {'detail': e.message})
node_list = []
# Retrive ports
@ -450,8 +447,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
port_list = self.ironicclient.call("port.list", **params)
except client_e.ClientException as e:
LOG.exception(_LE("Could not get ports from ironic. Reason: "
"%(detail)s"), {'detail': e.message})
LOG.exception("Could not get ports from ironic. Reason: "
"%(detail)s", {'detail': e.message})
port_list = []
# TODO(zhenguo): Add portgroups resources
@ -479,8 +476,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e:
LOG.exception(_LE("Could not get nodes from ironic. Reason: "
"%(detail)s"), {'detail': e.message})
LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s", {'detail': e.message})
node_list = []
return node_list
@ -501,8 +498,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try:
node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e:
LOG.exception(_LE("Could not get nodes from ironic. Reason: "
"%(detail)s"), {'detail': e.message})
LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s", {'detail': e.message})
node_list = []
return node_list
@ -560,4 +557,4 @@ class IronicDriver(base_driver.BaseEngineDriver):
timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_active,
instance)
timer.start(interval=CONF.ironic.api_retry_interval).wait()
LOG.info(_LI('Instance was successfully rebuilt'), instance=instance)
LOG.info('Instance was successfully rebuilt', instance=instance)

View File

@ -24,8 +24,6 @@ from taskflow.patterns import linear_flow
from mogan.common import exception
from mogan.common import flow_utils
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common import utils
from mogan import objects
@ -99,7 +97,7 @@ class OnFailureRescheduleTask(flow_utils.MoganTask):
# set the instance's status to error.
for failure in flow_failures.values():
if failure.check(*self.no_reschedule_exc_types):
LOG.error(_LE("Instance %s: create failed and no reschedule."),
LOG.error("Instance %s: create failed and no reschedule.",
instance.uuid)
return False
@ -108,7 +106,7 @@ class OnFailureRescheduleTask(flow_utils.MoganTask):
self._reschedule(context, cause, instance=instance, **kwargs)
return True
except exception.MoganException:
LOG.exception(_LE("Instance %s: rescheduling failed"),
LOG.exception("Instance %s: rescheduling failed",
instance.uuid)
return False
@ -163,7 +161,7 @@ class BuildNetworkTask(flow_utils.MoganTask):
# Set nics here, so we can clean up the
# created networks during reverting.
instance.nics = nics_obj
LOG.error(_LE("Instance %s: create network failed"),
LOG.error("Instance %s: create network failed",
instance.uuid)
raise exception.NetworkError(_(
"Build network for instance failed."))
@ -207,7 +205,7 @@ class CreateInstanceTask(flow_utils.MoganTask):
def execute(self, context, instance):
self.driver.spawn(context, instance)
LOG.info(_LI('Successfully provisioned Ironic node %s'),
LOG.info('Successfully provisioned Ironic node %s',
instance.node_uuid)
def revert(self, context, result, flow_failures, instance, **kwargs):

View File

@ -22,9 +22,6 @@ from oslo_utils import timeutils
from mogan.common import exception
from mogan.common import flow_utils
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common.i18n import _LW
from mogan.common import states
from mogan.common import utils
from mogan.conf import CONF
@ -49,7 +46,7 @@ class EngineManager(base_manager.BaseEngineManager):
try:
return objects.ComputePort.get(context, port_uuid)
except exception.NotFound:
LOG.warning(_LW("No compute port record for %(port)s"),
LOG.warning("No compute port record for %(port)s",
{'port': port_uuid})
def _get_compute_node(self, context, node_uuid):
@ -57,7 +54,7 @@ class EngineManager(base_manager.BaseEngineManager):
try:
return objects.ComputeNode.get(context, node_uuid)
except exception.NotFound:
LOG.warning(_LW("No compute node record for %(node)s"),
LOG.warning("No compute node record for %(node)s",
{'node': node_uuid})
def _init_compute_port(self, context, port):
@ -131,7 +128,7 @@ class EngineManager(base_manager.BaseEngineManager):
# Delete orphan compute node not reported by driver but still in db
for cn in compute_nodes_in_db:
if cn.node_uuid not in nodes:
LOG.info(_LI("Deleting orphan compute node %(id)s)"),
LOG.info("Deleting orphan compute node %(id)s)",
{'id': cn.node_uuid})
cn.destroy()
@ -147,8 +144,8 @@ class EngineManager(base_manager.BaseEngineManager):
nodes = self.driver.get_nodes_power_state()
except Exception as e:
LOG.warning(
_LW("Failed to retrieve node list when synchronizing power "
"states: %(msg)s") % {"msg": e})
("Failed to retrieve node list when synchronizing power "
"states: %(msg)s") % {"msg": e})
# Just retrun if we fail to get nodes real power state.
return
@ -156,9 +153,9 @@ class EngineManager(base_manager.BaseEngineManager):
if node.target_power_state is None}
if not node_dict:
LOG.warning(_LW("While synchronizing instance power states, "
"found none instance with stable power state "
"on the hypervisor."))
LOG.warning("While synchronizing instance power states, "
"found none instance with stable power state "
"on the hypervisor.")
return
def _sync(db_instance, node_power_state):
@ -173,8 +170,8 @@ class EngineManager(base_manager.BaseEngineManager):
try:
sync_instance_power_state()
except Exception:
LOG.exception(_LE("Periodic sync_power_state task had an "
"error while processing an instance."),
LOG.exception("Periodic sync_power_state task had an "
"error while processing an instance.",
instance=db_instance)
self._syncs_in_progress.pop(db_instance.uuid)
@ -190,8 +187,8 @@ class EngineManager(base_manager.BaseEngineManager):
if db_instance.status not in (states.ACTIVE, states.STOPPED):
if db_instance.status in states.UNSTABLE_STATES:
LOG.info(_LI("During sync_power_state the instance has a "
"pending task (%(task)s). Skip."),
LOG.info("During sync_power_state the instance has a "
"pending task (%(task)s). Skip.",
{'task': db_instance.status},
instance=db_instance)
continue
@ -225,18 +222,18 @@ class EngineManager(base_manager.BaseEngineManager):
# but the actual BM has not showed up on the hypervisor
# yet. In this case, let's allow the loop to continue
# and run the state sync in a later round
LOG.info(_LI("During sync_power_state the instance has a "
"pending task (%(task)s). Skip."),
LOG.info("During sync_power_state the instance has a "
"pending task (%(task)s). Skip.",
{'task': db_instance.task_state},
instance=db_instance)
return
if node_power_state != db_power_state:
LOG.info(_LI('During _sync_instance_power_state the DB '
'power_state (%(db_power_state)s) does not match '
'the node_power_state from the hypervisor '
'(%(node_power_state)s). Updating power_state in the '
'DB to match the hypervisor.'),
LOG.info('During _sync_instance_power_state the DB '
'power_state (%(db_power_state)s) does not match '
'the node_power_state from the hypervisor '
'(%(node_power_state)s). Updating power_state in the '
'DB to match the hypervisor.',
{'db_power_state': db_power_state,
'node_power_state': node_power_state},
instance=db_instance)
@ -253,17 +250,17 @@ class EngineManager(base_manager.BaseEngineManager):
nodes = self.driver.get_maintenance_node_list()
except Exception as e:
LOG.warning(
_LW("Failed to retrieve node list when synchronizing "
"maintenance states: %(msg)s") % {"msg": e})
"Failed to retrieve node list when synchronizing "
"maintenance states: %(msg)s" % {"msg": e})
# Just retrun if we fail to get nodes maintenance state.
return
node_dict = {node.instance_uuid: node for node in nodes}
if not node_dict:
LOG.warning(_LW("While synchronizing instance maintenance states, "
"found none node with instance associated on the "
"hypervisor."))
LOG.warning("While synchronizing instance maintenance states, "
"found none node with instance associated on the "
"hypervisor.")
return
db_instances = objects.Instance.list(context)
@ -274,8 +271,8 @@ class EngineManager(base_manager.BaseEngineManager):
# just skip the syncing process as the pending task should be goes
# to error state instead.
if instance.status in states.UNSTABLE_STATES:
LOG.info(_LI("During sync_maintenance_state the instance "
"has a pending task (%(task)s). Skip."),
LOG.info("During sync_maintenance_state the instance "
"has a pending task (%(task)s). Skip.",
{'task': instance.status},
instance=instance)
continue
@ -333,8 +330,8 @@ class EngineManager(base_manager.BaseEngineManager):
instance.save()
except Exception as e:
utils.process_event(fsm, instance, event='error')
LOG.error(_LE("Created instance %(uuid)s failed."
"Exception: %(exception)s"),
LOG.error("Created instance %(uuid)s failed."
"Exception: %(exception)s",
{"uuid": instance.uuid,
"exception": e})
return
@ -367,8 +364,8 @@ class EngineManager(base_manager.BaseEngineManager):
except Exception as e:
instance.power_state = states.NOSTATE
utils.process_event(fsm, instance, event='error')
LOG.error(_LE("Created instance %(uuid)s failed."
"Exception: %(exception)s"),
LOG.error("Created instance %(uuid)s failed."
"Exception: %(exception)s",
{"uuid": instance.uuid,
"exception": e})
else:
@ -379,7 +376,7 @@ class EngineManager(base_manager.BaseEngineManager):
instance.uuid)
instance.launched_at = timeutils.utcnow()
utils.process_event(fsm, instance, event='done')
LOG.info(_LI("Created instance %s successfully."), instance.uuid)
LOG.info("Created instance %s successfully.", instance.uuid)
finally:
return instance
@ -406,13 +403,13 @@ class EngineManager(base_manager.BaseEngineManager):
self._delete_instance(context, instance)
self._unplug_vifs(context, instance)
except exception.InstanceNotFound:
LOG.info(_LI("Instance disappeared during terminate"),
LOG.info("Instance disappeared during terminate",
instance=instance)
except Exception:
# As we're trying to delete always go to Error if something
# goes wrong that _delete_instance can't handle.
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Setting instance status to ERROR'),
LOG.exception('Setting instance status to ERROR',
instance=instance)
instance.power_state = states.NOSTATE
utils.process_event(fsm, instance, event='error')
@ -439,7 +436,7 @@ class EngineManager(base_manager.BaseEngineManager):
instance.power_state = self.driver.get_power_state(context,
instance.uuid)
utils.process_event(fsm, instance, event='done')
LOG.info(_LI('Successfully set node power state: %s'),
LOG.info('Successfully set node power state: %s',
state, instance=instance)
def _rebuild_instance(self, context, instance):
@ -464,14 +461,14 @@ class EngineManager(base_manager.BaseEngineManager):
self._rebuild_instance(context, instance)
except Exception as e:
utils.process_event(fsm, instance, event='error')
LOG.error(_LE("Rebuild instance %(uuid)s failed."
"Exception: %(exception)s"),
LOG.error("Rebuild instance %(uuid)s failed."
"Exception: %(exception)s",
{"uuid": instance.uuid,
"exception": e})
return
utils.process_event(fsm, instance, event='done')
LOG.info(_LI('Instance was successfully rebuilt'), instance=instance)
LOG.info('Instance was successfully rebuilt', instance=instance)
def list_availability_zones(self, context):
"""Get availability zone list."""

View File

@ -32,7 +32,6 @@ import six
from six.moves import range
from mogan.common import exception
from mogan.common.i18n import _LE
from mogan import conf
LOG = logging.getLogger(__name__)
@ -130,9 +129,9 @@ class GlanceClientWrapper(object):
else:
extra = 'done trying'
LOG.exception(_LE("Error contacting glance server "
"'%(server)s' for '%(method)s', "
"%(extra)s."),
LOG.exception("Error contacting glance server "
"'%(server)s' for '%(method)s', "
"%(extra)s.",
{'server': self.api_server,
'method': method, 'extra': extra})
if attempt == num_attempts:

View File

@ -16,7 +16,7 @@ from oslo_log import log as logging
from oslo_utils import excutils
from mogan.common import exception
from mogan.common.i18n import _, _LE
from mogan.common.i18n import _
from mogan.common import keystone
from mogan.conf import CONF
@ -126,7 +126,7 @@ class API(object):
if e.status_code == 404:
return []
with excutils.save_and_reraise_exception():
LOG.exception(_LE('Unable to access floating IP for %s'),
LOG.exception('Unable to access floating IP for %s',
', '.join(['%s %s' % (k, v)
for k, v in kwargs.items()]))

View File

@ -18,7 +18,6 @@ from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_versionedobjects import base as object_base
from mogan.common.i18n import _LE
from mogan.db import api as dbapi
from mogan import objects
from mogan.objects import base
@ -170,7 +169,7 @@ class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
try:
getattr(self, '_save_%s' % field)(context)
except AttributeError:
LOG.exception(_LE('No save handler for %s'), field,
LOG.exception('No save handler for %s', field,
instance=self)
except db_exc.DBReferenceError as exp:
if exp.key != 'instance_uuid':

View File

@ -19,7 +19,6 @@ Filter support
from oslo_log import log as logging
import six
from mogan.common.i18n import _LI
from mogan.scheduler import base_handler
LOG = logging.getLogger(__name__)
@ -76,13 +75,12 @@ class BaseFilterHandler(base_handler.BaseHandler):
"'%(inst_id)s'. Filter results: %(str_results)s"
) % msg_dict
msg_dict["str_results"] = ', '.join(
_LI("%(cls_name)s: (start: %(start)s, end: %(end)s)") % {
"cls_name": value[0], "start": value[1], "end": value[2]}
("%(cls_name)s: (start: %(start)s, end: %(end)s)") %
{"cls_name": value[0], "start": value[1], "end": value[2]}
for value in part_filter_results)
part_msg = _LI("Filtering removed all nodes for the request with "
"instance ID "
"'%(inst_id)s'. Filter results: %(str_results)s"
) % msg_dict
part_msg = ("Filtering removed all nodes for the request with "
"instance ID '%(inst_id)s'. "
"Filter results: %(str_results)s") % msg_dict
LOG.debug(full_msg)
LOG.info(part_msg)
@ -115,7 +113,7 @@ class BaseFilterHandler(base_handler.BaseHandler):
if filter_class.run_filter_for_index(index):
objs = filter_class.filter_all(list_objs, filter_properties)
if objs is None:
LOG.info(_LI("Filter %s returned 0 nodes"), cls_name)
LOG.info("Filter %s returned 0 nodes", cls_name)
full_filter_results.append((cls_name, None))
list_objs = None
break

View File

@ -22,8 +22,6 @@ from oslo_serialization import jsonutils
from mogan.common import exception
from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LW
from mogan.common import utils
from mogan.scheduler import driver
from mogan.scheduler import scheduler_options
@ -83,8 +81,8 @@ class FilterScheduler(driver.Scheduler):
return # no previously attempted nodes, skip
last_node = nodes[-1]
LOG.error(_LE("Error scheduling %(instance_id)s from last node: "
"%(last_node)s : %(exc)s"),
LOG.error("Error scheduling %(instance_id)s from last node: "
"%(last_node)s : %(exc)s",
{'instance_id': instance_id,
'last_node': last_node,
'exc': exc})
@ -182,8 +180,8 @@ class FilterScheduler(driver.Scheduler):
weighed_nodes = self._get_weighted_candidates(
context, request_spec, filter_properties)
if not weighed_nodes:
LOG.warning(_LW('No weighed nodes found for instance '
'with properties: %s'),
LOG.warning('No weighed nodes found for instance '
'with properties: %s',
request_spec.get('instance_type'))
raise exception.NoValidNode(_("No weighed nodes available"))

View File

@ -28,8 +28,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import timeutils
from mogan.common.i18n import _LE
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -58,8 +56,8 @@ class SchedulerOptions(object):
try:
return os.path.getmtime(filename)
except os.error:
LOG.exception(_LE("Could not stat scheduler options file "
"%(filename)s."),
LOG.exception("Could not stat scheduler options file "
"%(filename)s.",
{'filename': filename})
raise
@ -68,7 +66,7 @@ class SchedulerOptions(object):
try:
return json.load(handle)
except ValueError:
LOG.exception(_LE("Could not decode scheduler options."))
LOG.exception("Could not decode scheduler options.")
return {}
def _get_time_now(self):

View File

@ -47,7 +47,6 @@ from oslo_log import log as logging
import sqlalchemy
import sqlalchemy.exc
from mogan.common.i18n import _LE
from mogan.db.sqlalchemy import migration
from mogan.db.sqlalchemy import models
from mogan.tests import base
@ -140,8 +139,8 @@ class WalkVersionsMixin(object):
if check:
check(engine, data)
except Exception:
LOG.error(_LE("Failed to migrate to version %(version)s on engine "
"%(engine)s"),
LOG.error("Failed to migrate to version %(version)s on engine "
"%(engine)s",
{'version': version, 'engine': engine})
raise