X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fplugins%2FOpenStack%2FAodh%2Fnotifier.py;h=7a917d93fd439575e3da0fb2f293a2194de7fe6a;hb=822fb1930b4abdf834462d0cd26247b0960dcac0;hp=f7d50a8d27d4dfa6566a895f440a53d35928ea3f;hpb=e1c5c9ba4f44c3adc175421995e7171b6122b126;p=osm%2FMON.git diff --git a/osm_mon/plugins/OpenStack/Aodh/notifier.py b/osm_mon/plugins/OpenStack/Aodh/notifier.py index f7d50a8..7a917d9 100644 --- a/osm_mon/plugins/OpenStack/Aodh/notifier.py +++ b/osm_mon/plugins/OpenStack/Aodh/notifier.py @@ -44,7 +44,6 @@ sys.path.append(os.path.abspath(os.path.join(os.path.realpath(__file__), '..', ' from osm_mon.core.database import DatabaseManager 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.core.settings import Config @@ -91,42 +90,29 @@ class NotifierHandler(BaseHTTPRequestHandler): database_manager = DatabaseManager() alarm_id = values['alarm_id'] - # Get vim_uuid associated to alarm - creds = database_manager.get_credentials_for_alarm_id(alarm_id, 'openstack') - auth_token = Common.get_auth_token(creds.uuid) - endpoint = Common.get_endpoint("alarming", creds.uuid) - - # If authenticated generate and send response message - if auth_token is not None and endpoint is not None: - url = "{}/v2/alarms/%s".format(endpoint) % alarm_id - - # Get the resource_id of the triggered alarm - result = Common.perform_request( - url, auth_token, req_type="get") - alarm_details = json.loads(result.text) - gnocchi_rule = alarm_details['gnocchi_resources_threshold_rule'] - resource_id = gnocchi_rule['resource_id'] - - # Process an alarm notification if resource_id is valid - if resource_id is not None: - # Get date and time for response message - a_date = time.strftime("%d-%m-%Y") + " " + time.strftime("%X") - # Try generate and send response - try: - resp_message = response.generate_response( - 'notify_alarm', a_id=alarm_id, - r_id=resource_id, - sev=values['severity'], date=a_date, - state=values['current'], vim_type="openstack") - producer.notify_alarm( - '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.warning("No resource_id for alarm; no SO response sent.") - else: - log.warning("Authentication failure; SO notification not sent.") + alarm = database_manager.get_alarm(alarm_id, 'openstack') + # Process an alarm notification if resource_id is valid + # Get date and time for response message + a_date = time.strftime("%d-%m-%Y") + " " + time.strftime("%X") + # Try generate and send response + try: + resp_message = response.generate_response( + 'notify_alarm', a_id=alarm_id, + vdu_name=alarm.vdu_name, + vnf_member_index=alarm.vnf_member_index, + ns_id=alarm.ns_id, + metric_name=alarm.metric_name, + operation=alarm.operation, + threshold_value=alarm.threshold, + sev=values['severity'], + date=a_date, + state=values['current']) + producer.notify_alarm( + '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:") + except: log.exception("Could not notify alarm.")