X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fmessage_bus%2Fcommon_consumer;h=7221d0cd408e38c164404ff63ab786807b52ad54;hb=8b16911cdbe9f76c6d381bd96ee449e87b03541f;hp=9f261b78898dc0ccb88426b2c96ade7a3caab8a1;hpb=c7397b95dbaeebd7d872779eec809daed9e487cc;p=osm%2FMON.git diff --git a/osm_mon/core/message_bus/common_consumer b/osm_mon/core/message_bus/common_consumer index 9f261b7..7221d0c 100755 --- a/osm_mon/core/message_bus/common_consumer +++ b/osm_mon/core/message_bus/common_consumer @@ -22,8 +22,10 @@ import json import logging 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', @@ -34,17 +36,18 @@ log = logging.getLogger(__name__) from kafka import KafkaConsumer from kafka.errors import KafkaError -from plugins.OpenStack.Aodh import alarming -from plugins.OpenStack.common import Common -from plugins.OpenStack.Gnocchi import metrics +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 # Initialize servers server = {'server': 'localhost:9092'} # Initialize consumers for alarms and metrics -common_consumer = KafkaConsumer(group_id='osm_mon', - bootstrap_servers=server['server']) +common_consumer = KafkaConsumer(bootstrap_servers=server['server']) # Create OpenStack alarming and metric instances auth_token = None @@ -52,6 +55,9 @@ openstack_auth = Common() openstack_metrics = metrics.Metrics() openstack_alarms = alarming.Alarming() +# Create CloudWatch alarm and metric instances +cloudwatch_alarms = plugin_alarms() +cloudwatch_metrics = plugin_metrics() def get_vim_type(message): """Get the vim type that is required by the message.""" @@ -72,18 +78,20 @@ 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( message, openstack_auth, auth_token) - elif vim_type == "cloudwatch": + elif vim_type == "aws": + 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.") - else: + else: log.debug("vim_type is misconfigured or unsupported; %s", vim_type) @@ -94,7 +102,8 @@ try: log.info("This message is for the OpenStack plugin.") openstack_alarms.alarming(message, openstack_auth, auth_token) - elif vim_type == "cloudwatch": + elif vim_type == "aws": + cloudwatch_alarms.alarm_calls(message) log.info("This message is for the CloudWatch plugin.") elif vim_type == "vrops": @@ -111,7 +120,8 @@ try: log.info("This message is for the OpenStack plugin.") auth_token = openstack_auth._authenticate(message=message) - elif vim_type == "cloudwatch": + elif vim_type == "aws": + #TODO Access credentials later log.info("This message is for the CloudWatch plugin.") elif vim_type == "vrops":