Remove remaining log translation
Log translation support was removed during Pike cycle[1]. [1] https://review.opendev.org/c/openstack/oslo.i18n/+/446762 Also string interpolations should be delayed in logging to avoid unnecessary interpolation operations. Change-Id: Ifce960b10bae691f8117c4728821f9da13045fed Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -192,7 +192,7 @@ class AlarmTimeConstraint(base.Base):
|
|||||||
|
|
||||||
|
|
||||||
ALARMS_RULES = extension.ExtensionManager("aodh.alarm.rule")
|
ALARMS_RULES = extension.ExtensionManager("aodh.alarm.rule")
|
||||||
LOG.debug("alarm rules plugin loaded: %s" % ",".join(ALARMS_RULES.names()))
|
LOG.debug("alarm rules plugin loaded: %s", ",".join(ALARMS_RULES.names()))
|
||||||
|
|
||||||
ACTIONS_SCHEMA = extension.ExtensionManager(
|
ACTIONS_SCHEMA = extension.ExtensionManager(
|
||||||
notifier.AlarmNotifierService.NOTIFIER_EXTENSIONS_NAMESPACE).names()
|
notifier.AlarmNotifierService.NOTIFIER_EXTENSIONS_NAMESPACE).names()
|
||||||
|
@@ -158,7 +158,7 @@ class CompositeEvaluator(evaluator.Evaluator):
|
|||||||
self.rule_targets.append(rule)
|
self.rule_targets.append(rule)
|
||||||
return AlarmEvaluation(rule), OkEvaluation(rule)
|
return AlarmEvaluation(rule), OkEvaluation(rule)
|
||||||
else:
|
else:
|
||||||
LOG.error("Invalid rule type: %s" % alarm_rule['type'])
|
LOG.error("Invalid rule type: %s", alarm_rule['type'])
|
||||||
return False, False
|
return False, False
|
||||||
|
|
||||||
def _reason(self, alarm, new_state, rule_target_alarm):
|
def _reason(self, alarm, new_state, rule_target_alarm):
|
||||||
|
@@ -91,9 +91,9 @@ class GnocchiResourceThresholdEvaluator(GnocchiBase):
|
|||||||
rule['resource_id']),
|
rule['resource_id']),
|
||||||
[])
|
[])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = 'alarm statistics retrieval failed: %s' % e
|
msg = 'alarm statistics retrieval failed: %s'
|
||||||
LOG.warning(msg)
|
LOG.warning(msg, e)
|
||||||
raise threshold.InsufficientDataError(msg, [])
|
raise threshold.InsufficientDataError(msg % e, [])
|
||||||
|
|
||||||
|
|
||||||
class GnocchiAggregationMetricsThresholdEvaluator(GnocchiBase):
|
class GnocchiAggregationMetricsThresholdEvaluator(GnocchiBase):
|
||||||
@@ -136,9 +136,9 @@ class GnocchiAggregationMetricsThresholdEvaluator(GnocchiBase):
|
|||||||
'metrics in %s' % (rule['aggregation_method'],
|
'metrics in %s' % (rule['aggregation_method'],
|
||||||
rule['metrics']), [])
|
rule['metrics']), [])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = 'alarm statistics retrieval failed: %s' % e
|
msg = 'alarm statistics retrieval failed: %s'
|
||||||
LOG.warning(msg)
|
LOG.warning(msg, e)
|
||||||
raise threshold.InsufficientDataError(msg, [])
|
raise threshold.InsufficientDataError(msg % e, [])
|
||||||
|
|
||||||
|
|
||||||
class GnocchiAggregationResourcesThresholdEvaluator(GnocchiBase):
|
class GnocchiAggregationResourcesThresholdEvaluator(GnocchiBase):
|
||||||
@@ -177,6 +177,6 @@ class GnocchiAggregationResourcesThresholdEvaluator(GnocchiBase):
|
|||||||
'aggregation %s does not exist for at least one '
|
'aggregation %s does not exist for at least one '
|
||||||
'metric of the query' % rule['aggregation_method'], [])
|
'metric of the query' % rule['aggregation_method'], [])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = 'alarm statistics retrieval failed: %s' % e
|
msg = 'alarm statistics retrieval failed: %s'
|
||||||
LOG.warning(msg)
|
LOG.warning(msg, e)
|
||||||
raise threshold.InsufficientDataError(msg, [])
|
raise threshold.InsufficientDataError(msg % e, [])
|
||||||
|
@@ -51,7 +51,7 @@ class TrustHeatAlarmNotifier(notifier.AlarmNotifier):
|
|||||||
LOG.info(
|
LOG.info(
|
||||||
"Notifying alarm %(alarm_name)s %(alarm_id)s of %(severity)s "
|
"Notifying alarm %(alarm_name)s %(alarm_id)s of %(severity)s "
|
||||||
"priority from %(previous)s to %(current)s with action %(action)s"
|
"priority from %(previous)s to %(current)s with action %(action)s"
|
||||||
" because %(reason)s." %
|
" because %(reason)s.",
|
||||||
{'alarm_name': alarm_name,
|
{'alarm_name': alarm_name,
|
||||||
'alarm_id': alarm_id,
|
'alarm_id': alarm_id,
|
||||||
'severity': severity,
|
'severity': severity,
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
|
||||||
from aodh.i18n import _
|
|
||||||
from aodh import notifier
|
from aodh import notifier
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
@@ -28,13 +27,14 @@ class LogAlarmNotifier(notifier.AlarmNotifier):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def notify(action, alarm_id, alarm_name, severity, previous, current,
|
def notify(action, alarm_id, alarm_name, severity, previous, current,
|
||||||
reason, reason_data):
|
reason, reason_data):
|
||||||
LOG.info(_(
|
LOG.info(
|
||||||
"Notifying alarm %(alarm_name)s %(alarm_id)s of %(severity)s "
|
"Notifying alarm %(alarm_name)s %(alarm_id)s of %(severity)s "
|
||||||
"priority from %(previous)s to %(current)s with action %(action)s"
|
"priority from %(previous)s to %(current)s with action %(action)s"
|
||||||
" because %(reason)s.") % ({'alarm_name': alarm_name,
|
" because %(reason)s.",
|
||||||
'alarm_id': alarm_id,
|
{'alarm_name': alarm_name,
|
||||||
'severity': severity,
|
'alarm_id': alarm_id,
|
||||||
'previous': previous,
|
'severity': severity,
|
||||||
'current': current,
|
'previous': previous,
|
||||||
'action': action.geturl(),
|
'current': current,
|
||||||
'reason': reason}))
|
'action': action.geturl(),
|
||||||
|
'reason': reason})
|
||||||
|
@@ -67,11 +67,11 @@ class RestAlarmNotifier(notifier.AlarmNotifier):
|
|||||||
LOG.info(
|
LOG.info(
|
||||||
"Notifying alarm %(alarm_name)s %(alarm_id)s with severity"
|
"Notifying alarm %(alarm_name)s %(alarm_id)s with severity"
|
||||||
" %(severity)s from %(previous)s to %(current)s with action "
|
" %(severity)s from %(previous)s to %(current)s with action "
|
||||||
"%(action)s because %(reason)s. request-id: %(request_id)s " %
|
"%(action)s because %(reason)s. request-id: %(request_id)s",
|
||||||
({'alarm_name': alarm_name, 'alarm_id': alarm_id,
|
{'alarm_name': alarm_name, 'alarm_id': alarm_id,
|
||||||
'severity': severity, 'previous': previous,
|
'severity': severity, 'previous': previous,
|
||||||
'current': current, 'action': action, 'reason': reason,
|
'current': current, 'action': action, 'reason': reason,
|
||||||
'request_id': headers['x-openstack-request-id']}))
|
'request_id': headers['x-openstack-request-id']})
|
||||||
body = {'alarm_name': alarm_name, 'alarm_id': alarm_id,
|
body = {'alarm_name': alarm_name, 'alarm_id': alarm_id,
|
||||||
'severity': severity, 'previous': previous,
|
'severity': severity, 'previous': previous,
|
||||||
'current': current, 'reason': reason,
|
'current': current, 'reason': reason,
|
||||||
|
@@ -134,13 +134,13 @@ class ZaqarAlarmNotifier(notifier.AlarmNotifier):
|
|||||||
LOG.info(
|
LOG.info(
|
||||||
"Notifying alarm %(alarm_name)s %(alarm_id)s of %(severity)s "
|
"Notifying alarm %(alarm_name)s %(alarm_id)s of %(severity)s "
|
||||||
"priority from %(previous)s to %(current)s with action %(action)s"
|
"priority from %(previous)s to %(current)s with action %(action)s"
|
||||||
" because %(reason)s." % ({'alarm_name': alarm_name,
|
" because %(reason)s.", {'alarm_name': alarm_name,
|
||||||
'alarm_id': alarm_id,
|
'alarm_id': alarm_id,
|
||||||
'severity': severity,
|
'severity': severity,
|
||||||
'previous': previous,
|
'previous': previous,
|
||||||
'current': current,
|
'current': current,
|
||||||
'action': action,
|
'action': action,
|
||||||
'reason': reason}))
|
'reason': reason})
|
||||||
body = {'alarm_name': alarm_name, 'alarm_id': alarm_id,
|
body = {'alarm_name': alarm_name, 'alarm_id': alarm_id,
|
||||||
'severity': severity, 'previous': previous,
|
'severity': severity, 'previous': previous,
|
||||||
'current': current, 'reason': reason,
|
'current': current, 'reason': reason,
|
||||||
|
3
tox.ini
3
tox.ini
@@ -89,7 +89,8 @@ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
|||||||
# [H203] Use assertIs(Not)None to check for None.
|
# [H203] Use assertIs(Not)None to check for None.
|
||||||
# [H204] Use assert(Not)Equal to check for equality.
|
# [H204] Use assert(Not)Equal to check for equality.
|
||||||
# [H205] Use assert(Greater|Less)(Equal) for comparison.
|
# [H205] Use assert(Greater|Less)(Equal) for comparison.
|
||||||
enable-extensions=H106,H203,H204,H205
|
# [H904] Delay string interpolations at logging calls.
|
||||||
|
enable-extensions=H106,H203,H204,H205,H904
|
||||||
show-source = True
|
show-source = True
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
|
Reference in New Issue
Block a user