- def create_alarm(self,
- name: str,
- threshold: str,
- operation: str,
- severity: str,
- statistic: str,
- metric_name: str,
- tags: dict) -> Alarm:
- database.db.connect()
- try:
- with database.db.atomic():
- alarm = AlarmRepository.create(
- uuid=str(uuid.uuid4()),
- name=name,
- threshold=threshold,
- operation=operation.lower(),
- severity=severity.lower(),
- statistic=statistic.lower(),
- metric=metric_name
- )
- for k, v in tags.items():
- AlarmTagRepository.create(
- name=k,
- value=v,
- alarm=alarm
- )
- return alarm
+ def create_alarm(
+ self,
+ name: str,
+ threshold: float,
+ operation: str,
+ severity: str,
+ statistic: str,
+ metric_name: str,
+ action: str,
+ tags: dict,
+ ) -> Alarm:
+ log.debug("create_alarm")
+ alarm = Alarm(
+ name, severity, threshold, operation, statistic, metric_name, action, tags
+ )
+ self.common_db.create_alarm(alarm)
+ log.info("Alarm %s created", alarm.name)
+ return alarm