X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fmessage_bus%2Fcommon_consumer;h=7221d0cd408e38c164404ff63ab786807b52ad54;hb=8b16911cdbe9f76c6d381bd96ee449e87b03541f;hp=bb8ce0c5afa5a31b41d683f30691386f2e47dfa3;hpb=058ddc52db38655cc3c7a621859794780ee0305b;p=osm%2FMON.git diff --git a/osm_mon/core/message_bus/common_consumer b/osm_mon/core/message_bus/common_consumer index bb8ce0c..7221d0c 100755 --- a/osm_mon/core/message_bus/common_consumer +++ b/osm_mon/core/message_bus/common_consumer @@ -25,6 +25,7 @@ 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', @@ -39,13 +40,14 @@ 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 @@ -53,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.""" @@ -73,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) @@ -95,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": @@ -112,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":