Re-Revert "Revert "Migrates alarms to MongoDB"" approved by TSC

This reverts commit 628df021896fa8775f9743af62a4267b617cc35c.

Change-Id: Ie07a6856ee3f2e15c539d52afc4c7e5ecc07ca95
diff --git a/osm_mon/server/service.py b/osm_mon/server/service.py
index 1d546e3..60cb3ec 100755
--- a/osm_mon/server/service.py
+++ b/osm_mon/server/service.py
@@ -21,12 +21,10 @@
 # contact: bdiaz@whitestack.com or glavado@whitestack.com
 ##
 import logging
-import uuid
 
-from osm_mon.core import database
 from osm_mon.core.common_db import CommonDbClient
 from osm_mon.core.config import Config
-from osm_mon.core.database import AlarmRepository, Alarm, AlarmTagRepository
+from osm_mon.core.models import Alarm
 
 log = logging.getLogger(__name__)
 
@@ -38,41 +36,16 @@
 
     def create_alarm(self,
                      name: str,
-                     threshold: str,
+                     threshold: float,
                      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
-
-        finally:
-            database.db.close()
+        alarm = Alarm(name, severity, threshold, operation, statistic, metric_name, tags)
+        self.common_db.create_alarm(alarm)
+        return alarm
 
     def delete_alarm(self,
                      alarm_uuid: str) -> None:
-        database.db.connect()
-        try:
-            with database.db.atomic():
-                alarm = AlarmRepository.get(Alarm.uuid == alarm_uuid)
-                alarm.delete_instance()
-        finally:
-            database.db.close()
+        self.common_db.delete_alarm(alarm_uuid)