From: Gianpietro Lavado Date: Thu, 12 Apr 2018 19:39:50 +0000 (-0600) Subject: adds yaml support in common consumer X-Git-Tag: v4.0.0~16 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=e4be37f562f1d0c394d1ccdd0238202ec8f6f949;p=osm%2FMON.git adds yaml support in common consumer Change-Id: Ia6ae411cd4c3ad074455c0cae32d198c89d0f52e Signed-off-by: Gianpietro Lavado --- diff --git a/osm_mon/core/message_bus/common_consumer.py b/osm_mon/core/message_bus/common_consumer.py index 0ba003b..25aee43 100755 --- a/osm_mon/core/message_bus/common_consumer.py +++ b/osm_mon/core/message_bus/common_consumer.py @@ -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 diff --git a/requirements.txt b/requirements.txt index de09caa..39f18d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -41,3 +41,4 @@ pyopenssl six bottle peewee==3.1.* +pyyaml \ No newline at end of file