Refactors code in OpenStack plugin
[osm/MON.git] / osm_mon / plugins / CloudWatch / connection.py
index 609f6aa..5853ae9 100644 (file)
@@ -26,7 +26,6 @@ Connecting with AWS services --CloudWatch/EC2 using Required keys
 __author__ = "Wajeeha Hamid"
 __date__   = "18-September-2017"
 
-import sys
 import os
 
 try:
@@ -35,7 +34,7 @@ try:
     import boto.vpc
     import boto.ec2.cloudwatch
     import boto.ec2.connection
-    import logging as log
+    import logging 
     from boto.ec2.cloudwatch.alarm import MetricAlarm
     from boto.ec2.cloudwatch.dimension import Dimension
     from boto.sns import connect_to_region
@@ -44,12 +43,13 @@ try:
 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"""
 #-----------------------------------------------------------------------------------------------------------------------------
     def setEnvironment(self):  
-       try:
+        try:
             """Credentials for connecting to AWS-CloudWatch""" 
             #Reads from the environment variables
             self.AWS_KEY = os.environ.get("AWS_ACCESS_KEY_ID")
@@ -57,7 +57,7 @@ class Connection():
             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))