Updated vROPs plugin for using Common plugin consumer
[osm/MON.git] / osm_mon / core / message_bus / common_consumer
index 7221d0c..0255965 100755 (executable)
@@ -25,7 +25,6 @@ import sys
 import os
 
 sys.path.append("/root/MON")
-sys.path.append("../../plugins/CloudWatch")
 
 logging.basicConfig(filename='MON_plugins.log',
                     format='%(asctime)s %(message)s',
@@ -40,8 +39,10 @@ from osm_mon.plugins.OpenStack.Aodh import alarming
 from osm_mon.plugins.OpenStack.common import Common
 from osm_mon.plugins.OpenStack.Gnocchi import metrics
 
-from plugin_alarm import plugin_alarms
-from plugin_metric import plugin_metrics
+from osm_mon.plugins.CloudWatch.plugin_alarm import plugin_alarms
+from osm_mon.plugins.CloudWatch.plugin_metric import plugin_metrics
+
+from osm_mon.plugins.vRealiseOps import plugin_receiver
 
 # Initialize servers
 server = {'server': 'localhost:9092'}
@@ -59,6 +60,9 @@ openstack_alarms = alarming.Alarming()
 cloudwatch_alarms = plugin_alarms()
 cloudwatch_metrics = plugin_metrics()
 
+#Create vROps plugin_receiver class instance
+vrops_rcvr = plugin_receiver.PluginReceiver()
+
 def get_vim_type(message):
     """Get the vim type that is required by the message."""
     try:
@@ -78,7 +82,7 @@ try:
         if message.topic == "metric_request":
             # Check the vim desired by the message
             vim_type = get_vim_type(message)
-            
+
             if vim_type == "openstack":
                 log.info("This message is for the OpenStack plugin.")
                 openstack_metrics.metric_calls(
@@ -88,10 +92,11 @@ try:
                 cloudwatch_metrics.metric_calls(message)
                 log.info("This message is for the CloudWatch plugin.")
 
-            elif vim_type == "vrops":
-                log.info("This message is for the vROPs plugin.")
+            elif vim_type == "vmware":
+                log.info("This metric_request message is for the vROPs plugin.")
+                vrops_rcvr.consume(message)
 
-            else:   
+            else:
                 log.debug("vim_type is misconfigured or unsupported; %s",
                           vim_type)
 
@@ -106,8 +111,9 @@ try:
                 cloudwatch_alarms.alarm_calls(message)
                 log.info("This message is for the CloudWatch plugin.")
 
-            elif vim_type == "vrops":
-                log.info("This message is for the vROPs plugin.")
+            elif vim_type == "vmware":
+                log.info("This alarm_request message is for the vROPs plugin.")
+                vrops_rcvr.consume(message)
 
             else:
                 log.debug("vim_type is misconfigured or unsupported; %s",
@@ -124,8 +130,9 @@ try:
                 #TODO Access credentials later
                 log.info("This message is for the CloudWatch plugin.")
 
-            elif vim_type == "vrops":
-                log.info("This message is for the vROPs plugin.")
+            elif vim_type == "vmware":
+                log.info("This access_credentials message is for the vROPs plugin.")
+                vrops_rcvr.consume(message)
 
             else:
                 log.debug("vim_type is misconfigured or unsupported; %s",