- auth_token = self._common._authenticate()
- endpoint = self._common.get_endpoint("alarming")
-
- # List all of the alarms
- alarm_list = self.list_alarms(endpoint, auth_token)
-
- # TODO(mcgoughh): send a repsonse back to SO
- if alarm_list is not None:
- self.resp_status = True
- log.info("A list of alarms was generated: %s",
- alarm_list)
- else:
- self.resp_status = False
- log.warn("Failed to generae an alarm list")
+ # Check for a specifed: alarm_name, resource_uuid, severity
+ # and generate the appropriate list
+ list_details = values['alarm_list_request']
+ try:
+ name = list_details['alarm_name']
+ alarm_list = self.list_alarms(
+ endpoint, auth_token, alarm_name=name)
+ except Exception as a_name:
+ log.debug("No name specified for list:%s", a_name)
+ try:
+ resource = list_details['resource_uuid']
+ alarm_list = self.list_alarms(
+ endpoint, auth_token, resource_id=resource)
+ except Exception as r_id:
+ log.debug("No resource id specified for this list:\
+ %s", r_id)
+ try:
+ severe = list_details['severity']
+ alarm_list = self.list_alarms(
+ endpoint, auth_token, severity=severe)
+ except Exception as exc:
+ log.warn("No severity specified for list: %s.\
+ will return full list.", exc)
+ alarm_list = self.list_alarms(
+ endpoint, auth_token)
+
+ 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'])
+ 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.")