- endpoint = self.common.get_endpoint("metric")
- url = "{}/v1/metric?sort=name:asc".format(endpoint)
- result = self.common._perform_request(
- url, auth_token, req_type="get")
- metric_list = []
- metrics_partial = json.loads(result.text)
- for metric in metrics_partial:
- metric_list.append(metric)
-
- while len(json.loads(result.text)) > 0:
- last_metric_id = metrics_partial[-1]['id']
- url = "{}/v1/metric?sort=name:asc&marker={}".format(endpoint, last_metric_id)
- result = self.common._perform_request(
- url, auth_token, req_type="get")
- if len(json.loads(result.text)) > 0:
- metrics_partial = json.loads(result.text)
- for metric in metrics_partial:
- metric_list.append(metric)
-
- for metric in metric_list:
- name = metric['name']
- resource = metric['resource_id']
- if (name == METRIC_MAPPINGS[m_name] and resource == r_id):
- metric_id = metric['id']
- log.info("The required metric exists, an alarm will be created.")
- return metric_id
- except Exception as exc:
- log.info("Desired Gnocchi metric not found:%s", exc)
- return None
+ resp_message = self._response.generate_response(
+ key, cor_id=correlation_id, **kwargs)
+ log.info("Response Message: %s", resp_message)
+ self._producer.publish_alarm_response(
+ key, resp_message)
+ except Exception as e:
+ log.exception("Response creation failed:")
+ raise e