Remove log translations in scheduler 3/5

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.
This is the 3/5 commit.
Old commit will be abandoned: https://review.openstack.org/#/c/447822/

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

Change-Id: I0c1dd123ce8d08c797780c7706c684a939371719
Depends-On: I9fd264a443c634465b8548067f86ac14c1a51faa
Partial-Bug: #1674542
This commit is contained in:
yfzhao 2017-03-24 16:18:14 +08:00
parent ed19930c72
commit cd09242ba5
8 changed files with 51 additions and 60 deletions

View File

@ -25,7 +25,6 @@ from oslo_log import log
from manila import exception
from manila.i18n import _
from manila.i18n import _LE, _LI
from manila.scheduler.drivers import base
from manila.scheduler import scheduler_options
from manila.share import share_types
@ -265,8 +264,8 @@ class FilterScheduler(base.Scheduler):
if retry['num_attempts'] > max_attempts:
msg = _("Exceeded max scheduling attempts %(max_attempts)d for "
"share %(share_id)s") % {
"max_attempts": max_attempts,
"share_id": share_id
"max_attempts": max_attempts,
"share_id": share_id
}
raise exception.NoValidHost(reason=msg)
@ -285,12 +284,12 @@ class FilterScheduler(base.Scheduler):
return # no previously attempted hosts, skip
last_host = hosts[-1]
LOG.error(_LE("Error scheduling %(share_id)s from last share-service: "
"%(last_host)s : %(exc)s"), {
"share_id": share_id,
"last_host": last_host,
"exc": "exc"
})
LOG.error("Error scheduling %(share_id)s from last share-service: "
"%(last_host)s : %(exc)s", {
"share_id": share_id,
"last_host": last_host,
"exc": "exc"
})
def populate_filter_properties_share(self, request_spec,
filter_properties):
@ -310,14 +309,14 @@ class FilterScheduler(base.Scheduler):
def schedule_create_share_group(self, context, share_group_id,
request_spec, filter_properties):
LOG.info(_LI("Scheduling share group %s.") % share_group_id)
LOG.info("Scheduling share group %s." % share_group_id)
host = self._get_best_host_for_share_group(context, request_spec)
if not host:
msg = _("No hosts available for share group %s.") % share_group_id
raise exception.NoValidHost(reason=msg)
msg = _LI("Chose host %(host)s for create_share_group %(group)s.")
msg = "Chose host %(host)s for create_share_group %(group)s."
LOG.info(msg % {'host': host, 'group': share_group_id})
updated_share_group = base.share_group_update_db(

View File

@ -18,7 +18,6 @@ Filter support
"""
from oslo_log import log
from manila.i18n import _LI
from manila.scheduler import base_handler
LOG = log.getLogger(__name__)
@ -90,7 +89,7 @@ class BaseFilterHandler(base_handler.BaseHandler):
{'cls_name': cls_name})
return
list_objs = list(objs)
msg = (_LI("Filter %(cls_name)s returned %(obj_len)d host(s)")
msg = ("Filter %(cls_name)s returned %(obj_len)d host(s)"
% {'cls_name': cls_name, 'obj_len': len(list_objs)})
if not list_objs:
LOG.info(msg)

View File

@ -21,7 +21,6 @@ import math
from oslo_log import log
from manila.i18n import _LE, _LW
from manila.scheduler.filters import base_host
from manila.scheduler import utils
@ -37,8 +36,8 @@ class CapacityFilter(base_host.BaseHostFilter):
if host_state.free_capacity_gb is None:
# Fail Safe
LOG.error(_LE("Free capacity not set: "
"share node info collection broken."))
LOG.error("Free capacity not set: "
"share node info collection broken.")
return False
free_space = host_state.free_capacity_gb
@ -60,8 +59,8 @@ class CapacityFilter(base_host.BaseHostFilter):
return reserved == 0 and share_size <= free_space
total = float(total_space)
if total <= 0:
LOG.warning(_LW("Insufficient free space for share creation. "
"Total capacity is %(total).2f on host %(host)s."),
LOG.warning("Insufficient free space for share creation. "
"Total capacity is %(total).2f on host %(host)s.",
{"total": total,
"host": host_state.host})
return False
@ -94,12 +93,12 @@ class CapacityFilter(base_host.BaseHostFilter):
provisioned_ratio = ((host_state.provisioned_capacity_gb +
share_size) / total)
if provisioned_ratio > host_state.max_over_subscription_ratio:
LOG.warning(_LW(
LOG.warning(
"Insufficient free space for thin provisioning. "
"The ratio of provisioned capacity over total capacity "
"%(provisioned_ratio).2f would exceed the maximum over "
"subscription ratio %(oversub_ratio).2f on host "
"%(host)s."),
"%(host)s.",
{"provisioned_ratio": provisioned_ratio,
"oversub_ratio": host_state.max_over_subscription_ratio,
"host": host_state.host})
@ -112,15 +111,15 @@ class CapacityFilter(base_host.BaseHostFilter):
return adjusted_free_virtual >= share_size
elif (use_thin_logic and thin_provisioning and
host_state.max_over_subscription_ratio < 1):
LOG.error(_LE("Invalid max_over_subscription_ratio: %(ratio)s. "
"Valid value should be >= 1."),
LOG.error("Invalid max_over_subscription_ratio: %(ratio)s. "
"Valid value should be >= 1.",
{"ratio": host_state.max_over_subscription_ratio})
return False
if free < share_size:
LOG.warning(_LW("Insufficient free space for share creation "
"on host %(host)s (requested / avail): "
"%(requested)s/%(available)s"), msg_args)
LOG.warning("Insufficient free space for share creation "
"on host %(host)s (requested / avail): "
"%(requested)s/%(available)s", msg_args)
return False
return True

View File

@ -17,7 +17,6 @@ import six
from oslo_log import log as logging
from manila.i18n import _LI, _LW
from manila.scheduler.evaluator import evaluator
from manila.scheduler.filters import base_host
from manila.scheduler import utils
@ -56,18 +55,18 @@ class DriverFilter(base_host.BaseHostFilter):
# Check that the share types match
if extra_specs is None or 'share_backend_name' not in extra_specs:
LOG.warning(_LW("No 'share_backend_name' key in extra_specs. "
"Skipping share backend name check."))
LOG.warning("No 'share_backend_name' key in extra_specs. "
"Skipping share backend name check.")
elif (extra_specs['share_backend_name'] !=
host_stats['share_backend_name']):
LOG.warning(_LW("Share backend names do not match: '%(target)s' "
"vs '%(current)s' :: Skipping."),
LOG.warning("Share backend names do not match: '%(target)s'"
"vs '%(current)s' :: Skipping.",
{'target': extra_specs['share_backend_name'],
'current': host_stats['share_backend_name']})
return False
if stats['filter_function'] is None:
LOG.warning(_LW("Filter function not set :: passing host."))
LOG.warning("Filter function not set :: passing host.")
return True
try:
@ -76,13 +75,13 @@ class DriverFilter(base_host.BaseHostFilter):
except Exception as ex:
# Warn the admin for now that there is an error in the
# filter function.
LOG.warning(_LW("Error in filtering function "
"'%(function)s' : '%(error)s' :: failing host."),
LOG.warning("Error in filtering function "
"'%(function)s' : '%(error)s' :: failing host.",
{'function': stats['filter_function'],
'error': ex, })
return False
msg = _LI("Filter function result for host %(host)s: %(result)s.")
msg = "Filter function result for host %(host)s: %(result)s."
args = {'host': stats['host_stats']['host'],
'result': six.text_type(filter_result)}
LOG.info(msg, args)

View File

@ -33,7 +33,6 @@ import six
from manila import db
from manila import exception
from manila.i18n import _LI, _LW
from manila.scheduler.filters import base_host as base_host_filter
from manila.scheduler import utils as scheduler_utils
from manila.scheduler.weighers import base_host as base_host_weigher
@ -548,7 +547,7 @@ class HostManager(object):
# Warn about down services and remove them from host_state_map
if not utils.service_is_up(service) or service['disabled']:
LOG.warning(_LW("Share service is down. (host: %s).") % host)
LOG.warning("Share service is down. (host: %s)." % host)
continue
# Create and register host_state if not in host_state_map
@ -569,8 +568,8 @@ class HostManager(object):
# remove non-active hosts from host_state_map
nonactive_hosts = set(self.host_state_map.keys()) - active_hosts
for host in nonactive_hosts:
LOG.info(_LI("Removing non-active host: %(host)s from"
"scheduler cache."), {'host': host})
LOG.info("Removing non-active host: %(host)s from "
"scheduler cache.", {'host': host})
self.host_state_map.pop(host, None)
def get_all_host_states_share(self, context):

View File

@ -28,7 +28,6 @@ from manila.common import constants
from manila import context
from manila import db
from manila import exception
from manila.i18n import _LE, _LW
from manila import manager
from manila import rpc
from manila.share import rpcapi as share_rpcapi
@ -70,9 +69,9 @@ class SchedulerManager(manager.Manager):
'old': scheduler_driver,
'new': MAPPING[scheduler_driver],
}
LOG.warning(_LW("Scheduler driver path %(old)s is deprecated, "
"update your configuration to the new path "
"%(new)s"), msg_args)
LOG.warning("Scheduler driver path %(old)s is deprecated, "
"update your configuration to the new path "
"%(new)s", msg_args)
scheduler_driver = MAPPING[scheduler_driver]
self.driver = importutils.import_object(scheduler_driver)
@ -189,7 +188,7 @@ class SchedulerManager(manager.Manager):
def _set_share_state_and_notify(self, method, state, context, ex,
request_spec):
LOG.error(_LE("Failed to schedule %(method)s: %(ex)s"),
LOG.error("Failed to schedule %(method)s: %(ex)s",
{"method": method, "ex": ex})
properties = request_spec.get('share_properties', {})
@ -213,7 +212,7 @@ class SchedulerManager(manager.Manager):
share_rpcapi.ShareAPI().publish_service_capabilities(context)
def _set_share_group_error_state(self, method, context, ex, request_spec):
LOG.warning(_LW("Failed to schedule_%(method)s: %(ex)s"),
LOG.warning("Failed to schedule_%(method)s: %(ex)s",
{"method": method, "ex": ex})
share_group_state = {'status': constants.STATUS_ERROR}
@ -239,7 +238,7 @@ class SchedulerManager(manager.Manager):
def _set_share_replica_error_state(self, context, method, exc,
request_spec):
LOG.warning(_LW("Failed to schedule_%(method)s: %(exc)s"),
LOG.warning("Failed to schedule_%(method)s: %(exc)s",
{'method': method, 'exc': exc})
status_updates = {
'status': constants.STATUS_ERROR,

View File

@ -28,8 +28,6 @@ from oslo_log import log
from oslo_serialization import jsonutils
from oslo_utils import timeutils
from manila.i18n import _LE
scheduler_json_config_location_opt = cfg.StrOpt(
'scheduler_json_config_location',
default='',
@ -65,8 +63,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
@ -75,7 +73,7 @@ class SchedulerOptions(object):
try:
return jsonutils.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

@ -16,7 +16,6 @@
from oslo_log import log as logging
import six
from manila.i18n import _LI, _LW
from manila.scheduler.evaluator import evaluator
from manila.scheduler import utils
from manila.scheduler.weighers import base_host
@ -58,17 +57,17 @@ class GoodnessWeigher(base_host.BaseHostWeigher):
goodness_rating = 0
if stats['goodness_function'] is None:
LOG.warning(_LW("Goodness function not set :: defaulting to "
"minimal goodness rating of 0."))
LOG.warning("Goodness function not set :: defaulting to "
"minimal goodness rating of 0.")
else:
try:
goodness_result = self._run_evaluator(
stats['goodness_function'],
stats)
except Exception as ex:
LOG.warning(_LW("Error in goodness_function function "
"'%(function)s' : '%(error)s' :: Defaulting "
"to a goodness of 0."),
LOG.warning("Error in goodness_function function "
"'%(function)s' : '%(error)s' :: Defaulting "
"to a goodness of 0.",
{'function': stats['goodness_function'],
'error': ex, })
return goodness_rating
@ -77,14 +76,14 @@ class GoodnessWeigher(base_host.BaseHostWeigher):
if goodness_result:
goodness_rating = 100
elif goodness_result < 0 or goodness_result > 100:
LOG.warning(_LW("Invalid goodness result. Result must be "
"between 0 and 100. Result generated: '%s' "
":: Defaulting to a goodness of 0."),
LOG.warning("Invalid goodness result. Result must be "
"between 0 and 100. Result generated: '%s' "
":: Defaulting to a goodness of 0.",
goodness_result)
else:
goodness_rating = goodness_result
msg = _LI("Goodness function result for host %(host)s: %(result)s.")
msg = "Goodness function result for host %(host)s: %(result)s."
args = {'host': stats['host_stats']['host'],
'result': six.text_type(goodness_rating)}
LOG.info(msg, args)