diff --git a/ceilometer/alarm/rpc.py b/ceilometer/alarm/rpc.py index afe6cc120..aee59cf9e 100644 --- a/ceilometer/alarm/rpc.py +++ b/ceilometer/alarm/rpc.py @@ -44,5 +44,5 @@ class RPCAlarmNotifier(rpc_proxy.RpcProxy): 'alarm_id': alarm.alarm_id, 'previous': previous, 'current': alarm.state, - 'reason': reason}) + 'reason': unicode(reason)}) self.cast(context.get_admin_context(), msg) diff --git a/tests/alarm/test_rpc.py b/tests/alarm/test_rpc.py index ba7bfe7ab..85669e516 100644 --- a/tests/alarm/test_rpc.py +++ b/tests/alarm/test_rpc.py @@ -91,3 +91,8 @@ class TestRPCAlarmNotifier(base.TestCase): 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))