- auth_token = self._common._authenticate()
- endpoint = self._common.get_endpoint("alarming")
-
- # 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 = self._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 = self._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")
- self._producer.notify_alarm(
- 'notify_alarm', resp_message, 'alarm_response')
- log.info("Sent an alarm response to SO: %s", resp_message)
- except Exception as exc:
- log.warn("Couldn't notify SO of the alarm: %s", exc)
- else:
- log.warn("No resource_id for alarm; no SO response sent.")
- else:
- log.warn("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")
+ # Generate and send response
+ 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.publish_alarm_response(
+ 'notify_alarm', resp_message)
+ log.info("Sent alarm notification: %s", resp_message)