From cae650341754311d90bc7c7a0321787b6c0e315a Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Fri, 6 Jul 2018 16:04:19 -0300 Subject: [PATCH] [MON] Fixes notifier bug during alarm triggering Signed-off-by: Benjamin Diaz --- osm_mon/plugins/OpenStack/Aodh/notifier.py | 4 ++-- osm_mon/test/OpenStack/unit/test_notifier.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osm_mon/plugins/OpenStack/Aodh/notifier.py b/osm_mon/plugins/OpenStack/Aodh/notifier.py index 377404a..8f3f0fe 100644 --- a/osm_mon/plugins/OpenStack/Aodh/notifier.py +++ b/osm_mon/plugins/OpenStack/Aodh/notifier.py @@ -72,11 +72,11 @@ class NotifierHandler(BaseHTTPRequestHandler): post_data = post_data.decode() except AttributeError: pass - log.info("This alarm was triggered: %s", json.dumps(post_data)) + log.info("This alarm was triggered: %s", post_data) # Send alarm notification to message bus try: - self.notify_alarm(json.dumps(post_data)) + self.notify_alarm(json.loads(post_data)) except Exception: log.exception("Error notifying alarm") diff --git a/osm_mon/test/OpenStack/unit/test_notifier.py b/osm_mon/test/OpenStack/unit/test_notifier.py index 951bf10..a135cec 100644 --- a/osm_mon/test/OpenStack/unit/test_notifier.py +++ b/osm_mon/test/OpenStack/unit/test_notifier.py @@ -52,7 +52,7 @@ class Response(object): class RFile(): def read(self, content_length): - return post_data + return json.dumps(post_data, sort_keys=True) class MockNotifierHandler(NotifierHandler): @@ -98,7 +98,7 @@ class TestNotifier(unittest.TestCase): self.handler.do_POST() set_head.assert_called_once() - notify.assert_called_with(json.dumps(post_data)) + notify.assert_called_with(post_data) @mock.patch.object(KafkaProducer, "notify_alarm") @mock.patch.object(DatabaseManager, "get_alarm") -- 2.25.1