From: Helena McGough Date: Tue, 26 Sep 2017 08:42:47 +0000 (+0100) Subject: Updated logging for both OpenStack plugins X-Git-Tag: v4.0.0~75^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F97%2F2297%2F1;p=osm%2FMON.git Updated logging for both OpenStack plugins Signed-off-by: Helena McGough --- diff --git a/plugins/OpenStack/Aodh/alarming.py b/plugins/OpenStack/Aodh/alarming.py index 3c6d4d1..71ee743 100644 --- a/plugins/OpenStack/Aodh/alarming.py +++ b/plugins/OpenStack/Aodh/alarming.py @@ -22,7 +22,8 @@ """Carry out alarming requests via Aodh API.""" import json -import logging as log +import logging +log = logging.getLogger(__name__) from core.message_bus.producer import KafkaProducer @@ -102,6 +103,9 @@ class Alarming(object): # Generate a valid response message, send via producer try: + if alarm_status is True: + log.info("Alarm successfully created") + resp_message = self._response.generate_response( 'create_alarm_response', status=alarm_status, alarm_id=alarm_id, @@ -233,6 +237,7 @@ class Alarming(object): result = self._common._perform_request( url, auth_token, req_type="delete") if str(result.status_code) == "404": + log.info("Alarm doesn't exist: %s", result.status_code) # If status code is 404 alarm did not exist return False else: diff --git a/plugins/OpenStack/Aodh/plugin_instance.py b/plugins/OpenStack/Aodh/plugin_instance.py index 11bacf6..aaba1e4 100644 --- a/plugins/OpenStack/Aodh/plugin_instance.py +++ b/plugins/OpenStack/Aodh/plugin_instance.py @@ -21,7 +21,14 @@ ## """Aodh plugin for the OSM monitoring module.""" -import logging as log +import logging + +logging.basicConfig(filename='aodh_MON.log', format='%(asctime)s %(message)s', + datefmt='%m/%d/%Y %I:%M:%S %p', filemode='a', + level=logging.INFO) +log = logging.getLogger(__name__) + + try: import aodhclient except ImportError: diff --git a/plugins/OpenStack/Gnocchi/metrics.py b/plugins/OpenStack/Gnocchi/metrics.py index 7b13547..453b83b 100644 --- a/plugins/OpenStack/Gnocchi/metrics.py +++ b/plugins/OpenStack/Gnocchi/metrics.py @@ -23,7 +23,9 @@ import datetime import json -import logging as log +import logging +log = logging.getLogger(__name__) + import time from core.message_bus.producer import KafkaProducer diff --git a/plugins/OpenStack/Gnocchi/plugin_instance.py b/plugins/OpenStack/Gnocchi/plugin_instance.py index 7b516e8..983af3d 100644 --- a/plugins/OpenStack/Gnocchi/plugin_instance.py +++ b/plugins/OpenStack/Gnocchi/plugin_instance.py @@ -21,7 +21,12 @@ ## """Gnocchi plugin for the OSM monitoring module.""" -import logging as log +import logging + +logging.basicConfig(filename='gnocchi_MON.log', datefmt='%m/%d/%Y %I:%M:%S %p', + format='%(asctime)s %(message)s', filemode='a', + level=logging.INFO) +log = logging.getLogger(__name__) try: import gnocchiclient diff --git a/plugins/OpenStack/common.py b/plugins/OpenStack/common.py index eed122d..fe72acc 100644 --- a/plugins/OpenStack/common.py +++ b/plugins/OpenStack/common.py @@ -21,7 +21,8 @@ ## """Common methods for the OpenStack plugins.""" -import logging as log +import logging +log = logging.getLogger(__name__) from keystoneclient.v3 import client @@ -102,5 +103,8 @@ class Common(object): except Exception as e: log.warn("Exception thrown on request", e) + if response is not None: + log.warn("Request resulted in %s code and %s response", + response.status_code, response.text) return response diff --git a/plugins/OpenStack/response.py b/plugins/OpenStack/response.py index e59c7ca..5bb620b 100644 --- a/plugins/OpenStack/response.py +++ b/plugins/OpenStack/response.py @@ -22,7 +22,8 @@ """Generate valid responses to send back to the SO.""" import json -import logging as log +import logging +log = logging.getLogger(__name__) __author__ = "Helena McGough" diff --git a/plugins/OpenStack/settings.py b/plugins/OpenStack/settings.py index 4a443aa..d177dcf 100644 --- a/plugins/OpenStack/settings.py +++ b/plugins/OpenStack/settings.py @@ -21,9 +21,8 @@ ## """Configurations for the OpenStack plugins.""" -#from __future__ import unicode_literals - -import logging as log +import logging +log = logging.getLogger(__name__) import os from collections import namedtuple