adds yaml support in common consumer 68/5968/1
authorGianpietro Lavado <glavado@whitestack.com>
Thu, 12 Apr 2018 19:39:50 +0000 (13:39 -0600)
committerGianpietro Lavado <glavado@whitestack.com>
Thu, 12 Apr 2018 19:40:11 +0000 (13:40 -0600)
Change-Id: Ia6ae411cd4c3ad074455c0cae32d198c89d0f52e
Signed-off-by: Gianpietro Lavado <glavado@whitestack.com>
osm_mon/core/message_bus/common_consumer.py
requirements.txt

index 0ba003b..25aee43 100755 (executable)
@@ -23,6 +23,7 @@ import json
 import logging
 import os
 import sys
+import yaml
 
 logging.basicConfig(stream=sys.stdout,
                     format='%(asctime)s %(message)s',
@@ -97,7 +98,10 @@ log.info("Listening for alarm_request and metric_request messages")
 for message in common_consumer:
     log.info("Message arrived: %s", message)
     try:
-        values = json.loads(message.value)
+        try:
+            values = json.loads(message.value)
+        except:
+            values = yaml.safe_load(message.value)
         # Check the message topic
         if message.topic == "metric_request":
             # Check the vim desired by the message
index de09caa..39f18d3 100644 (file)
@@ -41,3 +41,4 @@ pyopenssl
 six
 bottle
 peewee==3.1.*
+pyyaml
\ No newline at end of file