summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7d13c9e)
Change-Id: Ifeac4c2364fee7a936919445ac47a379ea74ea31
Signed-off-by: javaid <usman.javaid@xflowresearch.com>
import json
import logging
import json
import logging
-logging.basicConfig(filename='MON_plugins.log',
- format='%(asctime)s %(message)s',
- datefmt='%m/%d/%Y %I:%M:%S %p', filemode='a',
- level=logging.INFO)
log = logging.getLogger(__name__)
class AccessCredentials():
log = logging.getLogger(__name__)
class AccessCredentials():
+ def logtest(self):
+ log.info("Access credentials sourced for CloudWatch MON plugin")
+
+
def access_credential_calls(self,message):
try:
message = json.loads(message.value)['access_config']
def access_credential_calls(self,message):
try:
message = json.loads(message.value)['access_config']
except Exception as e:
log.error("Access credentials not provided correctly: %s", str(e))
except Exception as e:
log.error("Access credentials not provided correctly: %s", str(e))
import boto.vpc
import boto.ec2.cloudwatch
import boto.ec2.connection
import boto.vpc
import boto.ec2.cloudwatch
import boto.ec2.connection
from boto.ec2.cloudwatch.alarm import MetricAlarm
from boto.ec2.cloudwatch.dimension import Dimension
from boto.sns import connect_to_region
from boto.ec2.cloudwatch.alarm import MetricAlarm
from boto.ec2.cloudwatch.dimension import Dimension
from boto.sns import connect_to_region
except:
exit("Boto not avialable. Try activating your virtualenv OR `pip install boto`")
except:
exit("Boto not avialable. Try activating your virtualenv OR `pip install boto`")
+log = logging.getLogger(__name__)
class Connection():
"""Connection Establishement with AWS -- VPC/EC2/CloudWatch"""
class Connection():
"""Connection Establishement with AWS -- VPC/EC2/CloudWatch"""
self.AWS_REGION = os.environ.get("AWS_EC2_REGION","us-west-2")
#TODO Read from the cloudwatch_credentials.txt file
self.AWS_REGION = os.environ.get("AWS_EC2_REGION","us-west-2")
#TODO Read from the cloudwatch_credentials.txt file
return self.connection_instance()
except Exception as e:
log.error("AWS Credentials not configured, Try setting the access credentials first %s: ",str(e))
return self.connection_instance()
except Exception as e:
log.error("AWS Credentials not configured, Try setting the access credentials first %s: ",str(e))
import datetime
import random
import json
import datetime
import random
import json
from random import randint
from operator import itemgetter
from connection import Connection
from random import randint
from operator import itemgetter
from connection import Connection
+log = logging.getLogger(__name__)
import sys
import datetime
import json
import sys
import datetime
import json
except:
exit("Boto not avialable. Try activating your virtualenv OR `pip install boto`")
except:
exit("Boto not avialable. Try activating your virtualenv OR `pip install boto`")
+log = logging.getLogger(__name__)
from jsmin import jsmin
from connection import Connection
from metric_alarms import MetricAlarm
from jsmin import jsmin
from connection import Connection
from metric_alarms import MetricAlarm
sys.path.append("../../core/message_bus")
from producer import KafkaProducer
sys.path.append("../../core/message_bus")
from producer import KafkaProducer
+log = logging.getLogger(__name__)
+
class plugin_alarms():
"""Receives Alarm info from MetricAlarm and connects with the consumer/producer"""
def __init__ (self):
class plugin_alarms():
"""Receives Alarm info from MetricAlarm and connects with the consumer/producer"""
def __init__ (self):
from metrics import Metrics
sys.path.append("../../core/message_bus")
from producer import KafkaProducer
from metrics import Metrics
sys.path.append("../../core/message_bus")
from producer import KafkaProducer
+import logging
+
+log = logging.getLogger(__name__)
class plugin_metrics():
"""Receives Alarm info from MetricAlarm and connects with the consumer/producer """
class plugin_metrics():
"""Receives Alarm info from MetricAlarm and connects with the consumer/producer """
#---------------------------------------------------------------------------------------------------------------------------
def metric_calls(self,message,aws_conn):
#---------------------------------------------------------------------------------------------------------------------------
def metric_calls(self,message,aws_conn):
- '''Consumer will consume the message from SO,
- 1) parse the message and trigger the methods ac
- cording to keys and topics provided in request.
-
- 2) The response from plugin is saved in json format.
-
- 3) The producer object then calls the producer response
- methods to send the response back to message bus
- '''
+ """Gets the message from the common consumer"""
try:
self.cloudwatch_conn = aws_conn['cloudwatch_connection']
try:
self.cloudwatch_conn = aws_conn['cloudwatch_connection']