adds yaml support in common consumer
[osm/MON.git] / osm_mon / core / message_bus / common_consumer.py
index e79e98a..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',
@@ -77,10 +78,12 @@ aws_access_credentials = AccessCredentials()
 vrops_rcvr = plugin_receiver.PluginReceiver()
 
 
-def get_vim_type(message):
+def get_vim_type(msg):
     """Get the vim type that is required by the message."""
     try:
-        return json.loads(message.value)["vim_type"].lower()
+        vim_uuid = json.loads(msg.value)["vim_uuid"].lower()
+        credentials = database_manager.get_credentials(vim_uuid)
+        return credentials.type
     except Exception as exc:
         log.warn("vim_type is not configured correctly; %s", exc)
     return None
@@ -95,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