From e4be37f562f1d0c394d1ccdd0238202ec8f6f949 Mon Sep 17 00:00:00 2001 From: Gianpietro Lavado Date: Thu, 12 Apr 2018 13:39:50 -0600 Subject: [PATCH] adds yaml support in common consumer Change-Id: Ia6ae411cd4c3ad074455c0cae32d198c89d0f52e Signed-off-by: Gianpietro Lavado --- osm_mon/core/message_bus/common_consumer.py | 6 +++++- requirements.txt | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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 -- 2.25.1