+ def configure_alarm(self, alarm_endpoint, metric_endpoint, auth_token, values, vim_config):
+ """Create requested alarm in Aodh."""
+ url = "{}/v2/alarms/".format(alarm_endpoint)
+
+ # Check if the desired alarm is supported
+ alarm_name = values['alarm_name'].lower()
+ metric_name = values['metric_name'].lower()
+ resource_id = values['resource_uuid']
+
+ if metric_name not in METRIC_MAPPINGS.keys():
+ log.warning("This metric is not supported.")
+ return None, False
+
+ # Check for the required metric
+ metric_id = self.check_for_metric(auth_token, metric_endpoint, metric_name, resource_id)
+
+ try:
+ if metric_id is not None:
+ # Create the alarm if metric is available
+ if 'granularity' in vim_config and 'granularity' not in values:
+ values['granularity'] = vim_config['granularity']
+ payload = self.check_payload(values, metric_name, resource_id,
+ alarm_name)
+ new_alarm = Common.perform_request(
+ url, auth_token, req_type="post", payload=payload)
+ return json.loads(new_alarm.text)['alarm_id'], True
+ else:
+ log.warning("The required Gnocchi metric does not exist.")
+ return None, False
+
+ except Exception as exc:
+ log.warning("Failed to create the alarm: %s", exc)
+ return None, False
+
+ def alarming(self, message, vim_uuid):