Browse Source

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
Corey Bryant 5 months ago
parent
commit
dbf6d2770d
2 changed files with 8 additions and 10 deletions
  1. 6
    7
      aodh/evaluator/composite.py
  2. 2
    3
      aodh/evaluator/event.py

+ 6
- 7
aodh/evaluator/composite.py View File

@@ -18,7 +18,6 @@ import stevedore
18 18
 
19 19
 from aodh import evaluator
20 20
 from aodh.evaluator import threshold
21
-from aodh.i18n import _
22 21
 
23 22
 LOG = log.getLogger(__name__)
24 23
 
@@ -177,14 +176,14 @@ class CompositeEvaluator(evaluator.Evaluator):
177 176
                   'rules': ', '.join(sorted(root_cause_rules)),
178 177
                   'description': STATE_CHANGE[new_state]}
179 178
         if transition:
180
-            reason = (_('Composite rule alarm with composition form: '
181
-                        '%(expression)s transition to %(state)s, due to '
182
-                        'rules: %(rules)s %(description)s') % params)
179
+            reason = (('Composite rule alarm with composition form: '
180
+                       '%(expression)s transition to %(state)s, due to '
181
+                       'rules: %(rules)s %(description)s') % params)
183 182
 
184 183
         else:
185
-            reason = (_('Composite rule alarm with composition form: '
186
-                        '%(expression)s remaining as %(state)s, due to '
187
-                        'rules: %(rules)s %(description)s') % params)
184
+            reason = (('Composite rule alarm with composition form: '
185
+                       '%(expression)s remaining as %(state)s, due to '
186
+                       'rules: %(rules)s %(description)s') % params)
188 187
 
189 188
         return reason, reason_data
190 189
 

+ 2
- 3
aodh/evaluator/event.py View File

@@ -22,7 +22,6 @@ from oslo_utils import timeutils
22 22
 import six
23 23
 
24 24
 from aodh import evaluator
25
-from aodh.i18n import _
26 25
 
27 26
 LOG = log.getLogger(__name__)
28 27
 
@@ -248,8 +247,8 @@ class EventAlarmEvaluator(evaluator.Evaluator):
248 247
         """Update alarm state and fire alarm via alarm notifier."""
249 248
 
250 249
         state = evaluator.ALARM
251
-        reason = (_('Event <id=%(id)s,event_type=%(event_type)s> hits the '
252
-                    'query <query=%(alarm_query)s>.') %
250
+        reason = (('Event <id=%(id)s,event_type=%(event_type)s> hits the '
251
+                   'query <query=%(alarm_query)s>.') %
253 252
                   {'id': event.id,
254 253
                    'event_type': event.get_value('event_type'),
255 254
                    'alarm_query': json.dumps(alarm.obj.rule['query'],

Loading…
Cancel
Save