X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fplugins%2FOpenStack%2FAodh%2Fnotifier.py;h=f7d50a8d27d4dfa6566a895f440a53d35928ea3f;hb=refs%2Fchanges%2F34%2F6134%2F25;hp=314548f557b77b03a3cedc6013e77f341a89933b;hpb=181cce8e28a9b6c5c6fa1fa8aa515de3b187a2e1;p=osm%2FMON.git
diff --git a/osm_mon/plugins/OpenStack/Aodh/notifier.py b/osm_mon/plugins/OpenStack/Aodh/notifier.py
index 314548f..f7d50a8 100644
--- a/osm_mon/plugins/OpenStack/Aodh/notifier.py
+++ b/osm_mon/plugins/OpenStack/Aodh/notifier.py
@@ -24,10 +24,10 @@
"""A Webserver to send alarm notifications from Aodh to the SO."""
import json
import logging
+import os
import sys
import time
-import os
from six.moves.BaseHTTPServer import BaseHTTPRequestHandler
from six.moves.BaseHTTPServer import HTTPServer
@@ -46,7 +46,7 @@ from osm_mon.core.message_bus.producer import KafkaProducer
from osm_mon.plugins.OpenStack.common import Common
from osm_mon.plugins.OpenStack.response import OpenStack_Response
-from osm_mon.plugins.OpenStack.settings import Config
+from osm_mon.core.settings import Config
class NotifierHandler(BaseHTTPRequestHandler):
@@ -61,7 +61,6 @@ class NotifierHandler(BaseHTTPRequestHandler):
def do_GET(self):
"""Get request functionality."""
self._set_headers()
- self.wfile.write("
hi!
")
def do_POST(self):
"""POST request function."""
@@ -70,7 +69,10 @@ class NotifierHandler(BaseHTTPRequestHandler):
# Gets the size of data
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
- self.wfile.write("POST!
")
+ try:
+ post_data = post_data.decode()
+ except AttributeError:
+ pass
log.info("This alarm was triggered: %s", json.loads(post_data))
# Generate a notify_alarm response for the SO
@@ -117,14 +119,14 @@ class NotifierHandler(BaseHTTPRequestHandler):
sev=values['severity'], date=a_date,
state=values['current'], vim_type="openstack")
producer.notify_alarm(
- 'notify_alarm', resp_message, 'alarm_response')
+ 'notify_alarm', resp_message)
log.info("Sent an alarm response to SO: %s", resp_message)
except Exception as exc:
log.exception("Couldn't notify SO of the alarm:")
else:
- log.warn("No resource_id for alarm; no SO response sent.")
+ log.warning("No resource_id for alarm; no SO response sent.")
else:
- log.warn("Authentication failure; SO notification not sent.")
+ log.warning("Authentication failure; SO notification not sent.")
except:
log.exception("Could not notify alarm.")
@@ -138,7 +140,7 @@ def run(server_class=HTTPServer, handler_class=NotifierHandler, port=8662):
log.info("Starting alarm notifier server on port: %s", port)
httpd.serve_forever()
except Exception as exc:
- log.warn("Failed to start webserver, %s", exc)
+ log.warning("Failed to start webserver, %s", exc)
if __name__ == "__main__":