+ alarm_list = self.list_alarms(
+ endpoint, auth_token, list_details)
+
+ try:
+ # Generate and send a list response back
+ resp_message = self._response.generate_response(
+ 'list_alarm_response', alarm_list=alarm_list,
+ cor_id=list_details['correlation_id'])
+ log.info("Response Message: %s", resp_message)
+ self._producer.list_alarm_response(
+ 'list_alarm_response', resp_message,
+ 'alarm_response')
+ except Exception as exc:
+ log.warn("Failed to send a valid response back.")
+
+ elif message.key == "delete_alarm_request":
+ request_details = values['alarm_delete_request']
+ alarm_id = request_details['alarm_uuid']
+
+ resp_status = self.delete_alarm(
+ endpoint, auth_token, alarm_id)
+
+ # Generate and send a response message
+ try:
+ resp_message = self._response.generate_response(
+ 'delete_alarm_response', alarm_id=alarm_id,
+ status=resp_status,
+ cor_id=request_details['correlation_id'])
+ log.info("Response message: %s", resp_message)
+ self._producer.delete_alarm_response(
+ 'delete_alarm_response', resp_message,
+ 'alarm_response')
+ except Exception as exc:
+ log.warn("Failed to create delete reponse:%s", exc)
+
+ elif message.key == "acknowledge_alarm":
+ # Acknowledge that an alarm has been dealt with by the SO
+ alarm_id = values['ack_details']['alarm_uuid']
+
+ response = self.update_alarm_state(
+ endpoint, auth_token, alarm_id)
+
+ # Log if an alarm was reset
+ if response is True:
+ log.info("Acknowledged the alarm and cleared it.")
+ else:
+ log.warn("Failed to acknowledge/clear the alarm.")
+
+ elif message.key == "update_alarm_request":
+ # Update alarm configurations
+ alarm_details = values['alarm_update_request']
+
+ alarm_id, status = self.update_alarm(
+ endpoint, auth_token, alarm_details)
+
+ # Generate a response for an update request
+ try:
+ resp_message = self._response.generate_response(
+ 'update_alarm_response', alarm_id=alarm_id,
+ cor_id=alarm_details['correlation_id'],
+ status=status)
+ log.info("Response message: %s", resp_message)
+ self._producer.update_alarm_response(
+ 'update_alarm_response', resp_message,
+ 'alarm_response')
+ except Exception as exc:
+ log.warn("Failed to send an update response:%s", exc)