From dbf6d2770dcd97d2ef2939ca735309e44b946c4d Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Fri, 26 Oct 2018 13:58:56 -0400 Subject: [PATCH] PY3: Ensure _refresh is passed str type for reason Drop the use of oslo.i18n's Message class when defining the reason argument that is passed to _refresh(). Ensuing code that _refresh() uses, in particular pymysql [1], expects a unicode str type rather than an oslo_i18n._message.Message type. [1] https://github.com/PyMySQL/PyMySQL/blob/v0.9.2/pymysql/converters.py#L68 Change-Id: Icc59edc8a91ba7ae6929e853f1bf09bd25cdc039 Closes-Bug: #1799406 --- aodh/evaluator/composite.py | 13 ++++++------- aodh/evaluator/event.py | 5 ++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/aodh/evaluator/composite.py b/aodh/evaluator/composite.py index f7f140078..a780c8dd0 100644 --- a/aodh/evaluator/composite.py +++ b/aodh/evaluator/composite.py @@ -18,7 +18,6 @@ import stevedore from aodh import evaluator from aodh.evaluator import threshold -from aodh.i18n import _ LOG = log.getLogger(__name__) @@ -177,14 +176,14 @@ class CompositeEvaluator(evaluator.Evaluator): 'rules': ', '.join(sorted(root_cause_rules)), 'description': STATE_CHANGE[new_state]} if transition: - reason = (_('Composite rule alarm with composition form: ' - '%(expression)s transition to %(state)s, due to ' - 'rules: %(rules)s %(description)s') % params) + reason = (('Composite rule alarm with composition form: ' + '%(expression)s transition to %(state)s, due to ' + 'rules: %(rules)s %(description)s') % params) else: - reason = (_('Composite rule alarm with composition form: ' - '%(expression)s remaining as %(state)s, due to ' - 'rules: %(rules)s %(description)s') % params) + reason = (('Composite rule alarm with composition form: ' + '%(expression)s remaining as %(state)s, due to ' + 'rules: %(rules)s %(description)s') % params) return reason, reason_data diff --git a/aodh/evaluator/event.py b/aodh/evaluator/event.py index d90130ca9..0ba95f28c 100644 --- a/aodh/evaluator/event.py +++ b/aodh/evaluator/event.py @@ -22,7 +22,6 @@ from oslo_utils import timeutils import six from aodh import evaluator -from aodh.i18n import _ LOG = log.getLogger(__name__) @@ -248,8 +247,8 @@ class EventAlarmEvaluator(evaluator.Evaluator): """Update alarm state and fire alarm via alarm notifier.""" state = evaluator.ALARM - reason = (_('Event hits the ' - 'query .') % + reason = (('Event hits the ' + 'query .') % {'id': event.id, 'event_type': event.get_value('event_type'), 'alarm_query': json.dumps(alarm.obj.rule['query'],