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

View File

@ -25,7 +25,6 @@ import six
from six.moves import http_client from six.moves import http_client
from mogan.common.i18n import _ from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.conf import CONF from mogan.conf import CONF
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -63,7 +62,7 @@ class MoganException(Exception):
except Exception: except Exception:
# kwargs doesn't match a variable in self._msg_fmt # kwargs doesn't match a variable in self._msg_fmt
# log the issue and the kwargs # 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(): for name, value in kwargs.items():
LOG.error("%s: %s" % (name, value)) 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 "_" # The primary translation function using the well-known name "_"
_ = _translators.primary _ = _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 import exception
from mogan.common.i18n import _ from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.conf import auth as mogan_auth from mogan.conf import auth as mogan_auth
from mogan.conf import CONF from mogan.conf import CONF
@ -64,7 +63,7 @@ def ks_exceptions(f):
kaexception.MissingRequiredOptions) as e: kaexception.MissingRequiredOptions) as e:
raise exception.ConfigInvalid(six.text_type(e)) raise exception.ConfigInvalid(six.text_type(e))
except Exception as 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)}) {'msg': six.text_type(e)})
raise exception.KeystoneFailure(six.text_type(e)) raise exception.KeystoneFailure(six.text_type(e))
return wrapper return wrapper

View File

@ -26,7 +26,6 @@ import sys
import wsme import wsme
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _LW
_ENFORCER = None _ENFORCER = None
CONF = cfg.CONF 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 # NOTE: this method is obsoleted by authorize(), but retained for
# backwards compatibility in case it has been used downstream. # backwards compatibility in case it has been used downstream.
# It may be removed in the Pike cycle. # It may be removed in the Pike cycle.
LOG.warning(_LW( LOG.warning("Deprecation warning: calls to mogan.common.policy.enforce() "
"Deprecation warning: calls to mogan.common.policy.enforce() " "should be replaced with authorize(). This method may be "
"should be replaced with authorize(). This method may be removed " "removed in a future release.")
"in a future release."))
enforcer = get_enforcer() enforcer = get_enforcer()
return enforcer.enforce(rule, target, creds, do_raise=do_raise, 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 config
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _ from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common import rpc from mogan.common import rpc
from mogan.conf import CONF from mogan.conf import CONF
from mogan import objects from mogan import objects
@ -61,8 +59,8 @@ class RPCService(service.Service):
periodic_interval_max=CONF.periodic_interval, periodic_interval_max=CONF.periodic_interval,
context=admin_context) context=admin_context)
LOG.info(_LI('Created RPC server for service %(service)s on host ' LOG.info('Created RPC server for service %(service)s on host '
'%(host)s.'), '%(host)s.',
{'service': self.topic, 'host': self.host}) {'service': self.topic, 'host': self.host})
def stop(self): def stop(self):
@ -70,17 +68,17 @@ class RPCService(service.Service):
self.rpcserver.stop() self.rpcserver.stop()
self.rpcserver.wait() self.rpcserver.wait()
except Exception as e: except Exception as e:
LOG.exception(_LE('Service error occurred when stopping the ' LOG.exception('Service error occurred when stopping the '
'RPC server. Error: %s'), e) 'RPC server. Error: %s', e)
try: try:
self.manager.del_host() self.manager.del_host()
except Exception as e: except Exception as e:
LOG.exception(_LE('Service error occurred when cleaning up ' LOG.exception('Service error occurred when cleaning up '
'the RPC manager. Error: %s'), e) 'the RPC manager. Error: %s', e)
super(RPCService, self).stop(graceful=True) super(RPCService, self).stop(graceful=True)
LOG.info(_LI('Stopped RPC server for service %(service)s on host ' LOG.info('Stopped RPC server for service %(service)s on host '
'%(host)s.'), '%(host)s.',
{'service': self.topic, 'host': self.host}) {'service': self.topic, 'host': self.host})

View File

@ -22,7 +22,6 @@ from oslo_log import log as logging
import six import six
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _LW
from mogan.common import states from mogan.common import states
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -39,9 +38,9 @@ def safe_rstrip(value, chars=None):
""" """
if not isinstance(value, six.string_types): if not isinstance(value, six.string_types):
LOG.warning(_LW("Failed to remove trailing character. Returning " LOG.warning("Failed to remove trailing character. Returning "
"original object. Supplied object is not a string: " "original object. Supplied object is not a string: "
"%s,"), value) "%s,", value)
return value return value
return value.rstrip(chars) or 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 sqlalchemy.sql.expression import desc
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _, _LW from mogan.common.i18n import _
from mogan.db import api from mogan.db import api
from mogan.db.sqlalchemy import models from mogan.db.sqlalchemy import models
@ -702,8 +702,8 @@ class Connection(api.Connection):
usages[resource].reserved += delta usages[resource].reserved += delta
if unders: if unders:
LOG.warning(_LW("Change will make usage less than 0 for the " LOG.warning("Change will make usage less than 0 for the "
"following resources: %s"), unders) "following resources: %s", unders)
if overs: if overs:
usages = {k: dict(in_use=v.in_use, reserved=v.reserved, usages = {k: dict(in_use=v.in_use, reserved=v.reserved,
allocated=allocated.get(k, 0)) allocated=allocated.get(k, 0))

View File

@ -21,7 +21,6 @@ from oslo_utils import uuidutils
import six import six
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _LI
from mogan.common import states from mogan.common import states
from mogan.common import utils from mogan.common import utils
from mogan.conf import CONF from mogan.conf import CONF
@ -199,8 +198,8 @@ class API(object):
if max_net_count < min_count: if max_net_count < min_count:
raise exception.PortLimitExceeded() raise exception.PortLimitExceeded()
elif max_net_count < max_count: elif max_net_count < max_count:
LOG.info(_LI("max count reduced from %(max_count)d to " LOG.info("max count reduced from %(max_count)d to "
"%(max_net_count)d due to network port quota"), "%(max_net_count)d due to network port quota",
{'max_count': max_count, {'max_count': max_count,
'max_net_count': max_net_count}) 'max_net_count': max_net_count})
max_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_log import log as logging
from oslo_utils import importutils from oslo_utils import importutils
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common import utils from mogan.common import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -128,14 +126,14 @@ def load_engine_driver(engine_driver):
""" """
if not 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) sys.exit(1)
LOG.info(_LI("Loading engine driver '%s'"), engine_driver) LOG.info("Loading engine driver '%s'", engine_driver)
try: try:
driver = importutils.import_object( driver = importutils.import_object(
'mogan.engine.baremetal.%s' % engine_driver) 'mogan.engine.baremetal.%s' % engine_driver)
return utils.check_isinstance(driver, BaseEngineDriver) return utils.check_isinstance(driver, BaseEngineDriver)
except ImportError: except ImportError:
LOG.exception(_LE("Unable to load the baremetal driver")) LOG.exception("Unable to load the baremetal driver")
sys.exit(1) sys.exit(1)

View File

@ -22,9 +22,6 @@ import six
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _ 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 ironic
from mogan.common import states from mogan.common import states
from mogan.conf import CONF from mogan.conf import CONF
@ -52,7 +49,7 @@ def map_power_state(state):
try: try:
return _POWER_STATE_MAP[state] return _POWER_STATE_MAP[state]
except KeyError: except KeyError:
LOG.warning(_LW("Power state %s not found."), state) LOG.warning("Power state %s not found.", state)
return states.NOSTATE return states.NOSTATE
@ -110,8 +107,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
properties[prop] = int(node.properties.get(prop, 0)) properties[prop] = int(node.properties.get(prop, 0))
except (TypeError, ValueError): except (TypeError, ValueError):
LOG.warning(_LW('Node %(uuid)s has a malformed "%(prop)s". ' LOG.warning('Node %(uuid)s has a malformed "%(prop)s". '
'It should be an integer.'), 'It should be an integer.',
{'uuid': node.uuid, 'prop': prop}) {'uuid': node.uuid, 'prop': prop})
properties[prop] = 0 properties[prop] = 0
@ -144,8 +141,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
if len(parts) == 2 and parts[0] and parts[1]: if len(parts) == 2 and parts[0] and parts[1]:
nodes_extra_specs[parts[0].strip()] = parts[1] nodes_extra_specs[parts[0].strip()] = parts[1]
else: else:
LOG.warning(_LW("Ignoring malformed capability '%s'. " LOG.warning("Ignoring malformed capability '%s'. "
"Format should be 'key:val'."), capability) "Format should be 'key:val'.", capability)
dic = { dic = {
'cpus': cpus, 'cpus': cpus,
@ -203,9 +200,9 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
self.ironicclient.call('node.update', node.uuid, patch) self.ironicclient.call('node.update', node.uuid, patch)
except ironic_exc.BadRequest as e: except ironic_exc.BadRequest as e:
LOG.warning(_LW("Failed to remove deploy parameters from node " LOG.warning("Failed to remove deploy parameters from node "
"%(node)s when unprovisioning the instance " "%(node)s when unprovisioning the instance "
"%(instance)s: %(reason)s"), "%(instance)s: %(reason)s",
{'node': node.uuid, 'instance': instance.uuid, {'node': node.uuid, 'instance': instance.uuid,
'reason': six.text_type(e)}) 'reason': six.text_type(e)})
@ -317,8 +314,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
ironic_states.ACTIVE) ironic_states.ACTIVE)
except Exception as e: except Exception as e:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
msg = (_LE("Failed to request Ironic to provision instance " msg = ("Failed to request Ironic to provision instance "
"%(inst)s: %(reason)s"), "%(inst)s: %(reason)s",
{'inst': instance.uuid, {'inst': instance.uuid,
'reason': six.text_type(e)}) 'reason': six.text_type(e)})
LOG.error(msg) LOG.error(msg)
@ -327,12 +324,12 @@ class IronicDriver(base_driver.BaseEngineDriver):
instance) instance)
try: try:
timer.start(interval=CONF.ironic.api_retry_interval).wait() 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) node.uuid, instance=instance)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_LE("Error deploying instance %(instance)s on " LOG.error("Error deploying instance %(instance)s on "
"baremetal node %(node)s."), "baremetal node %(node)s.",
{'instance': instance.uuid, {'instance': instance.uuid,
'node': node_uuid}) 'node': node_uuid})
@ -402,7 +399,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
node = self._validate_instance_and_node(instance) node = self._validate_instance_and_node(instance)
except exception.InstanceNotFound: except exception.InstanceNotFound:
LOG.warning(_LW("Destroy called on non-existing instance %s."), LOG.warning("Destroy called on non-existing instance %s.",
instance.uuid) instance.uuid)
return return
@ -414,7 +411,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
# removed from ironic node. # removed from ironic node.
self._remove_instance_info_from_node(node, instance) 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) node.uuid, instance=instance)
def get_available_resources(self): def get_available_resources(self):
@ -437,8 +434,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
node_list = self.ironicclient.call("node.list", **params) node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e: except client_e.ClientException as e:
LOG.exception(_LE("Could not get nodes from ironic. Reason: " LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s"), {'detail': e.message}) "%(detail)s", {'detail': e.message})
node_list = [] node_list = []
# Retrive ports # Retrive ports
@ -450,8 +447,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
port_list = self.ironicclient.call("port.list", **params) port_list = self.ironicclient.call("port.list", **params)
except client_e.ClientException as e: except client_e.ClientException as e:
LOG.exception(_LE("Could not get ports from ironic. Reason: " LOG.exception("Could not get ports from ironic. Reason: "
"%(detail)s"), {'detail': e.message}) "%(detail)s", {'detail': e.message})
port_list = [] port_list = []
# TODO(zhenguo): Add portgroups resources # TODO(zhenguo): Add portgroups resources
@ -479,8 +476,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
node_list = self.ironicclient.call("node.list", **params) node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e: except client_e.ClientException as e:
LOG.exception(_LE("Could not get nodes from ironic. Reason: " LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s"), {'detail': e.message}) "%(detail)s", {'detail': e.message})
node_list = [] node_list = []
return node_list return node_list
@ -501,8 +498,8 @@ class IronicDriver(base_driver.BaseEngineDriver):
try: try:
node_list = self.ironicclient.call("node.list", **params) node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e: except client_e.ClientException as e:
LOG.exception(_LE("Could not get nodes from ironic. Reason: " LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s"), {'detail': e.message}) "%(detail)s", {'detail': e.message})
node_list = [] node_list = []
return node_list return node_list
@ -560,4 +557,4 @@ class IronicDriver(base_driver.BaseEngineDriver):
timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_active, timer = loopingcall.FixedIntervalLoopingCall(self._wait_for_active,
instance) instance)
timer.start(interval=CONF.ironic.api_retry_interval).wait() 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 exception
from mogan.common import flow_utils from mogan.common import flow_utils
from mogan.common.i18n import _ from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LI
from mogan.common import utils from mogan.common import utils
from mogan import objects from mogan import objects
@ -99,7 +97,7 @@ class OnFailureRescheduleTask(flow_utils.MoganTask):
# set the instance's status to error. # set the instance's status to error.
for failure in flow_failures.values(): for failure in flow_failures.values():
if failure.check(*self.no_reschedule_exc_types): 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) instance.uuid)
return False return False
@ -108,7 +106,7 @@ class OnFailureRescheduleTask(flow_utils.MoganTask):
self._reschedule(context, cause, instance=instance, **kwargs) self._reschedule(context, cause, instance=instance, **kwargs)
return True return True
except exception.MoganException: except exception.MoganException:
LOG.exception(_LE("Instance %s: rescheduling failed"), LOG.exception("Instance %s: rescheduling failed",
instance.uuid) instance.uuid)
return False return False
@ -163,7 +161,7 @@ class BuildNetworkTask(flow_utils.MoganTask):
# Set nics here, so we can clean up the # Set nics here, so we can clean up the
# created networks during reverting. # created networks during reverting.
instance.nics = nics_obj instance.nics = nics_obj
LOG.error(_LE("Instance %s: create network failed"), LOG.error("Instance %s: create network failed",
instance.uuid) instance.uuid)
raise exception.NetworkError(_( raise exception.NetworkError(_(
"Build network for instance failed.")) "Build network for instance failed."))
@ -207,7 +205,7 @@ class CreateInstanceTask(flow_utils.MoganTask):
def execute(self, context, instance): def execute(self, context, instance):
self.driver.spawn(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) instance.node_uuid)
def revert(self, context, result, flow_failures, instance, **kwargs): 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 exception
from mogan.common import flow_utils from mogan.common import flow_utils
from mogan.common.i18n import _ 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 states
from mogan.common import utils from mogan.common import utils
from mogan.conf import CONF from mogan.conf import CONF
@ -49,7 +46,7 @@ class EngineManager(base_manager.BaseEngineManager):
try: try:
return objects.ComputePort.get(context, port_uuid) return objects.ComputePort.get(context, port_uuid)
except exception.NotFound: 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}) {'port': port_uuid})
def _get_compute_node(self, context, node_uuid): def _get_compute_node(self, context, node_uuid):
@ -57,7 +54,7 @@ class EngineManager(base_manager.BaseEngineManager):
try: try:
return objects.ComputeNode.get(context, node_uuid) return objects.ComputeNode.get(context, node_uuid)
except exception.NotFound: 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}) {'node': node_uuid})
def _init_compute_port(self, context, port): 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 # Delete orphan compute node not reported by driver but still in db
for cn in compute_nodes_in_db: for cn in compute_nodes_in_db:
if cn.node_uuid not in nodes: 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}) {'id': cn.node_uuid})
cn.destroy() cn.destroy()
@ -147,8 +144,8 @@ class EngineManager(base_manager.BaseEngineManager):
nodes = self.driver.get_nodes_power_state() nodes = self.driver.get_nodes_power_state()
except Exception as e: except Exception as e:
LOG.warning( LOG.warning(
_LW("Failed to retrieve node list when synchronizing power " ("Failed to retrieve node list when synchronizing power "
"states: %(msg)s") % {"msg": e}) "states: %(msg)s") % {"msg": e})
# Just retrun if we fail to get nodes real power state. # Just retrun if we fail to get nodes real power state.
return return
@ -156,9 +153,9 @@ class EngineManager(base_manager.BaseEngineManager):
if node.target_power_state is None} if node.target_power_state is None}
if not node_dict: if not node_dict:
LOG.warning(_LW("While synchronizing instance power states, " LOG.warning("While synchronizing instance power states, "
"found none instance with stable power state " "found none instance with stable power state "
"on the hypervisor.")) "on the hypervisor.")
return return
def _sync(db_instance, node_power_state): def _sync(db_instance, node_power_state):
@ -173,8 +170,8 @@ class EngineManager(base_manager.BaseEngineManager):
try: try:
sync_instance_power_state() sync_instance_power_state()
except Exception: except Exception:
LOG.exception(_LE("Periodic sync_power_state task had an " LOG.exception("Periodic sync_power_state task had an "
"error while processing an instance."), "error while processing an instance.",
instance=db_instance) instance=db_instance)
self._syncs_in_progress.pop(db_instance.uuid) 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 not in (states.ACTIVE, states.STOPPED):
if db_instance.status in states.UNSTABLE_STATES: if db_instance.status in states.UNSTABLE_STATES:
LOG.info(_LI("During sync_power_state the instance has a " LOG.info("During sync_power_state the instance has a "
"pending task (%(task)s). Skip."), "pending task (%(task)s). Skip.",
{'task': db_instance.status}, {'task': db_instance.status},
instance=db_instance) instance=db_instance)
continue continue
@ -225,18 +222,18 @@ class EngineManager(base_manager.BaseEngineManager):
# but the actual BM has not showed up on the hypervisor # but the actual BM has not showed up on the hypervisor
# yet. In this case, let's allow the loop to continue # yet. In this case, let's allow the loop to continue
# and run the state sync in a later round # and run the state sync in a later round
LOG.info(_LI("During sync_power_state the instance has a " LOG.info("During sync_power_state the instance has a "
"pending task (%(task)s). Skip."), "pending task (%(task)s). Skip.",
{'task': db_instance.task_state}, {'task': db_instance.task_state},
instance=db_instance) instance=db_instance)
return return
if node_power_state != db_power_state: if node_power_state != db_power_state:
LOG.info(_LI('During _sync_instance_power_state the DB ' LOG.info('During _sync_instance_power_state the DB '
'power_state (%(db_power_state)s) does not match ' 'power_state (%(db_power_state)s) does not match '
'the node_power_state from the hypervisor ' 'the node_power_state from the hypervisor '
'(%(node_power_state)s). Updating power_state in the ' '(%(node_power_state)s). Updating power_state in the '
'DB to match the hypervisor.'), 'DB to match the hypervisor.',
{'db_power_state': db_power_state, {'db_power_state': db_power_state,
'node_power_state': node_power_state}, 'node_power_state': node_power_state},
instance=db_instance) instance=db_instance)
@ -253,17 +250,17 @@ class EngineManager(base_manager.BaseEngineManager):
nodes = self.driver.get_maintenance_node_list() nodes = self.driver.get_maintenance_node_list()
except Exception as e: except Exception as e:
LOG.warning( LOG.warning(
_LW("Failed to retrieve node list when synchronizing " "Failed to retrieve node list when synchronizing "
"maintenance states: %(msg)s") % {"msg": e}) "maintenance states: %(msg)s" % {"msg": e})
# Just retrun if we fail to get nodes maintenance state. # Just retrun if we fail to get nodes maintenance state.
return return
node_dict = {node.instance_uuid: node for node in nodes} node_dict = {node.instance_uuid: node for node in nodes}
if not node_dict: if not node_dict:
LOG.warning(_LW("While synchronizing instance maintenance states, " LOG.warning("While synchronizing instance maintenance states, "
"found none node with instance associated on the " "found none node with instance associated on the "
"hypervisor.")) "hypervisor.")
return return
db_instances = objects.Instance.list(context) 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 # just skip the syncing process as the pending task should be goes
# to error state instead. # to error state instead.
if instance.status in states.UNSTABLE_STATES: if instance.status in states.UNSTABLE_STATES:
LOG.info(_LI("During sync_maintenance_state the instance " LOG.info("During sync_maintenance_state the instance "
"has a pending task (%(task)s). Skip."), "has a pending task (%(task)s). Skip.",
{'task': instance.status}, {'task': instance.status},
instance=instance) instance=instance)
continue continue
@ -333,8 +330,8 @@ class EngineManager(base_manager.BaseEngineManager):
instance.save() instance.save()
except Exception as e: except Exception as e:
utils.process_event(fsm, instance, event='error') utils.process_event(fsm, instance, event='error')
LOG.error(_LE("Created instance %(uuid)s failed." LOG.error("Created instance %(uuid)s failed."
"Exception: %(exception)s"), "Exception: %(exception)s",
{"uuid": instance.uuid, {"uuid": instance.uuid,
"exception": e}) "exception": e})
return return
@ -367,8 +364,8 @@ class EngineManager(base_manager.BaseEngineManager):
except Exception as e: except Exception as e:
instance.power_state = states.NOSTATE instance.power_state = states.NOSTATE
utils.process_event(fsm, instance, event='error') utils.process_event(fsm, instance, event='error')
LOG.error(_LE("Created instance %(uuid)s failed." LOG.error("Created instance %(uuid)s failed."
"Exception: %(exception)s"), "Exception: %(exception)s",
{"uuid": instance.uuid, {"uuid": instance.uuid,
"exception": e}) "exception": e})
else: else:
@ -379,7 +376,7 @@ class EngineManager(base_manager.BaseEngineManager):
instance.uuid) instance.uuid)
instance.launched_at = timeutils.utcnow() instance.launched_at = timeutils.utcnow()
utils.process_event(fsm, instance, event='done') 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: finally:
return instance return instance
@ -406,13 +403,13 @@ class EngineManager(base_manager.BaseEngineManager):
self._delete_instance(context, instance) self._delete_instance(context, instance)
self._unplug_vifs(context, instance) self._unplug_vifs(context, instance)
except exception.InstanceNotFound: except exception.InstanceNotFound:
LOG.info(_LI("Instance disappeared during terminate"), LOG.info("Instance disappeared during terminate",
instance=instance) instance=instance)
except Exception: except Exception:
# As we're trying to delete always go to Error if something # As we're trying to delete always go to Error if something
# goes wrong that _delete_instance can't handle. # goes wrong that _delete_instance can't handle.
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.exception(_LE('Setting instance status to ERROR'), LOG.exception('Setting instance status to ERROR',
instance=instance) instance=instance)
instance.power_state = states.NOSTATE instance.power_state = states.NOSTATE
utils.process_event(fsm, instance, event='error') 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.power_state = self.driver.get_power_state(context,
instance.uuid) instance.uuid)
utils.process_event(fsm, instance, event='done') 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) state, instance=instance)
def _rebuild_instance(self, context, instance): def _rebuild_instance(self, context, instance):
@ -464,14 +461,14 @@ class EngineManager(base_manager.BaseEngineManager):
self._rebuild_instance(context, instance) self._rebuild_instance(context, instance)
except Exception as e: except Exception as e:
utils.process_event(fsm, instance, event='error') utils.process_event(fsm, instance, event='error')
LOG.error(_LE("Rebuild instance %(uuid)s failed." LOG.error("Rebuild instance %(uuid)s failed."
"Exception: %(exception)s"), "Exception: %(exception)s",
{"uuid": instance.uuid, {"uuid": instance.uuid,
"exception": e}) "exception": e})
return return
utils.process_event(fsm, instance, event='done') 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): def list_availability_zones(self, context):
"""Get availability zone list.""" """Get availability zone list."""

View File

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

View File

@ -16,7 +16,7 @@ from oslo_log import log as logging
from oslo_utils import excutils from oslo_utils import excutils
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _, _LE from mogan.common.i18n import _
from mogan.common import keystone from mogan.common import keystone
from mogan.conf import CONF from mogan.conf import CONF
@ -126,7 +126,7 @@ class API(object):
if e.status_code == 404: if e.status_code == 404:
return [] return []
with excutils.save_and_reraise_exception(): 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) ', '.join(['%s %s' % (k, v)
for k, v in kwargs.items()])) 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_log import log as logging
from oslo_versionedobjects import base as object_base from oslo_versionedobjects import base as object_base
from mogan.common.i18n import _LE
from mogan.db import api as dbapi from mogan.db import api as dbapi
from mogan import objects from mogan import objects
from mogan.objects import base from mogan.objects import base
@ -170,7 +169,7 @@ class Instance(base.MoganObject, object_base.VersionedObjectDictCompat):
try: try:
getattr(self, '_save_%s' % field)(context) getattr(self, '_save_%s' % field)(context)
except AttributeError: except AttributeError:
LOG.exception(_LE('No save handler for %s'), field, LOG.exception('No save handler for %s', field,
instance=self) instance=self)
except db_exc.DBReferenceError as exp: except db_exc.DBReferenceError as exp:
if exp.key != 'instance_uuid': if exp.key != 'instance_uuid':

View File

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

View File

@ -22,8 +22,6 @@ from oslo_serialization import jsonutils
from mogan.common import exception from mogan.common import exception
from mogan.common.i18n import _ from mogan.common.i18n import _
from mogan.common.i18n import _LE
from mogan.common.i18n import _LW
from mogan.common import utils from mogan.common import utils
from mogan.scheduler import driver from mogan.scheduler import driver
from mogan.scheduler import scheduler_options from mogan.scheduler import scheduler_options
@ -83,8 +81,8 @@ class FilterScheduler(driver.Scheduler):
return # no previously attempted nodes, skip return # no previously attempted nodes, skip
last_node = nodes[-1] last_node = nodes[-1]
LOG.error(_LE("Error scheduling %(instance_id)s from last node: " LOG.error("Error scheduling %(instance_id)s from last node: "
"%(last_node)s : %(exc)s"), "%(last_node)s : %(exc)s",
{'instance_id': instance_id, {'instance_id': instance_id,
'last_node': last_node, 'last_node': last_node,
'exc': exc}) 'exc': exc})
@ -182,8 +180,8 @@ class FilterScheduler(driver.Scheduler):
weighed_nodes = self._get_weighted_candidates( weighed_nodes = self._get_weighted_candidates(
context, request_spec, filter_properties) context, request_spec, filter_properties)
if not weighed_nodes: if not weighed_nodes:
LOG.warning(_LW('No weighed nodes found for instance ' LOG.warning('No weighed nodes found for instance '
'with properties: %s'), 'with properties: %s',
request_spec.get('instance_type')) request_spec.get('instance_type'))
raise exception.NoValidNode(_("No weighed nodes available")) 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_log import log as logging
from oslo_utils import timeutils from oslo_utils import timeutils
from mogan.common.i18n import _LE
CONF = cfg.CONF CONF = cfg.CONF
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -58,8 +56,8 @@ class SchedulerOptions(object):
try: try:
return os.path.getmtime(filename) return os.path.getmtime(filename)
except os.error: except os.error:
LOG.exception(_LE("Could not stat scheduler options file " LOG.exception("Could not stat scheduler options file "
"%(filename)s."), "%(filename)s.",
{'filename': filename}) {'filename': filename})
raise raise
@ -68,7 +66,7 @@ class SchedulerOptions(object):
try: try:
return json.load(handle) return json.load(handle)
except ValueError: except ValueError:
LOG.exception(_LE("Could not decode scheduler options.")) LOG.exception("Could not decode scheduler options.")
return {} return {}
def _get_time_now(self): def _get_time_now(self):

View File

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