Skip to content

Commit

Permalink
Notify with string representation of alarm reason
Browse files Browse the repository at this point in the history
Fixes bug 1227668

Ensure string representation of alarm reason is passed to the
alarm notifier over RPC (as opposed to a gettextutils.Message
instance).

Change-Id: I6a840789f83068ee5721cb139b06cf0071240152
  • Loading branch information
Eoghan Glynn committed Sep 20, 2013
1 parent 4a05b59 commit f8796ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ceilometer/alarm/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ def notify(self, alarm, previous, reason):
'alarm_id': alarm.alarm_id,
'previous': previous,
'current': alarm.state,
'reason': reason})
'reason': unicode(reason)})
self.cast(context.get_admin_context(), msg)
5 changes: 5 additions & 0 deletions tests/alarm/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,8 @@ def test_notify_alarm(self):
self.alarms[i].state)
self.assertEqual(self.notified[i][1]["args"]["data"]["reason"],
"what? %d" % i)

def test_notify_non_string_reason(self):
self.notifier.notify(self.alarms[0], 'ok', 42)
reason = self.notified[0][1]['args']['data']['reason']
self.assertTrue(isinstance(reason, basestring))

0 comments on commit f8796ee

Please sign in to comment.