+
+ def check_for_metric(self, auth_token, m_name, r_id):
+ """Check for the alarm metric."""
+ try:
+ endpoint = self._common.get_endpoint("metric")
+
+ url = "{}/v1/metric/".format(endpoint)
+ metric_list = self._common._perform_request(
+ url, auth_token, req_type="get")
+
+ for metric in json.loads(metric_list.text):
+ name = metric['name']
+ resource = metric['resource_id']
+ if (name == 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