X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fmessage_bus%2Fcommon_consumer;h=efbb12218cc36062c7ba6058a03d667daefc74ba;hb=0215787170470859168d861b666c4e92b37e3743;hp=de0c4ed8a64f2f3ba235dbe70d37fc0d27376d44;hpb=249a52f718d192b4e0311c815e1de57db4b9e008;p=osm%2FMON.git diff --git a/osm_mon/core/message_bus/common_consumer b/osm_mon/core/message_bus/common_consumer index de0c4ed..efbb122 100755 --- a/osm_mon/core/message_bus/common_consumer +++ b/osm_mon/core/message_bus/common_consumer @@ -41,9 +41,18 @@ from osm_mon.plugins.OpenStack.Gnocchi import 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.CloudWatch.connection import Connection +from osm_mon.plugins.CloudWatch.access_credentials import AccessCredentials + +from osm_mon.plugins.vRealiseOps import plugin_receiver # Initialize servers -server = {'server': 'localhost:9092'} +if "BROKER_URI" in os.environ: + server = {'server': os.getenv("BROKER_URI")} +else: + server = {'server': 'localhost:9092'} + + # Initialize consumers for alarms and metrics common_consumer = KafkaConsumer(bootstrap_servers=server['server']) @@ -57,6 +66,11 @@ openstack_alarms = alarming.Alarming() # Create CloudWatch alarm and metric instances cloudwatch_alarms = plugin_alarms() cloudwatch_metrics = plugin_metrics() +aws_connection = Connection() +aws_access_credentials = AccessCredentials() + +#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.""" @@ -77,20 +91,22 @@ 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 == "aws": - cloudwatch_metrics.metric_calls(message) log.info("This message is for the CloudWatch plugin.") + aws_conn = aws_connection.setEnvironment() + cloudwatch_metrics.metric_calls(message,aws_conn) - 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) @@ -102,11 +118,13 @@ try: openstack_alarms.alarming(message, openstack_auth, auth_token) elif vim_type == "aws": - cloudwatch_alarms.alarm_calls(message) log.info("This message is for the CloudWatch plugin.") + aws_conn = aws_connection.setEnvironment() + cloudwatch_alarms.alarm_calls(message, aws_conn) - 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", @@ -120,11 +138,12 @@ try: auth_token = openstack_auth._authenticate(message=message) elif vim_type == "aws": - #TODO Access credentials later log.info("This message is for the CloudWatch plugin.") + aws_access_credentials.access_credential_calls(message) - 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",