Minor fixes for MON Evaluator & Dashboarder
Change-Id: I1f2b1f786809aa84e2ee2cddbf401a03e504ff47
Signed-off-by: Gianpietro Lavado <glavado@whitestack.com>
diff --git a/MANIFEST.in b/MANIFEST.in
index 845273b..d95867d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -22,5 +22,5 @@
include requirements.txt
include test-requirements.txt
include README.rst
-recursive-include osm_mon *.py *.xml *.sh *.yaml
+recursive-include osm_mon *.py *.xml *.sh *.yaml *.json
recursive-include devops-stages *
diff --git a/osm_mon/core/models.py b/osm_mon/core/models.py
index 1810c9b..ca25d8b 100644
--- a/osm_mon/core/models.py
+++ b/osm_mon/core/models.py
@@ -44,7 +44,8 @@
'threshold': self.threshold,
'statistic': self.statistic,
'metric': self.metric,
- 'tags': self.tags
+ 'tags': self.tags,
+ 'operation': self.operation
}
return alarm
@@ -54,8 +55,9 @@
alarm.uuid = data.get('uuid', str(uuid.uuid4()))
alarm.name = data.get('name')
alarm.severity = data.get('severity')
- alarm.threshold = data.get('threshold')
+ alarm.threshold = float(data.get('threshold'))
alarm.statistic = data.get('statistic')
alarm.metric = data.get('metric')
alarm.tags = data.get('tags')
+ alarm.operation = data.get('operation')
return alarm
diff --git a/osm_mon/dashboarder/service.py b/osm_mon/dashboarder/service.py
index 10dc0f7..74812b5 100644
--- a/osm_mon/dashboarder/service.py
+++ b/osm_mon/dashboarder/service.py
@@ -25,6 +25,7 @@
from osm_mon.core.common_db import CommonDbClient
from osm_mon.core.config import Config
import osm_mon.dashboarder.backends.grafana as grafana
+from osm_mon import __path__ as mon_path
log = logging.getLogger(__name__)
@@ -46,7 +47,7 @@
project_id = project['_id']
# Collect Project IDs for periodical dashboard clean-up
osm_resource_uids.append(project_id)
- dashboard_path = '/mon/osm_mon/dashboarder/templates/project_scoped.json'
+ dashboard_path = '{}/dashboarder/templates/project_scoped.json'.format(mon_path)
if project_id not in dashboard_uids:
project_name = project['name']
grafana.create_dashboard(project_id, project_name,
@@ -60,7 +61,7 @@
nsrs = self.common_db.get_nsrs()
for nsr in nsrs:
nsr_id = nsr['_id']
- dashboard_path = '/mon/osm_mon/dashboarder/templates/ns_scoped.json'
+ dashboard_path = '{}/dashboarder/templates/ns_scoped.json'.format(mon_path)
# Collect NS IDs for periodical dashboard clean-up
osm_resource_uids.append(nsr_id)
# Check if the NSR's VNFDs contain metrics
diff --git a/osm_mon/evaluator/evaluator.py b/osm_mon/evaluator/evaluator.py
index cc9a8ad..7e86743 100644
--- a/osm_mon/evaluator/evaluator.py
+++ b/osm_mon/evaluator/evaluator.py
@@ -79,8 +79,8 @@
def _build_alarm_response(self, alarm: Alarm, status: AlarmStatus):
response = ResponseBuilder()
tags = {}
- for tag in alarm.tags:
- tags[tag.name] = tag.value
+ for name, value in alarm.tags.items():
+ tags[name] = value
now = time.strftime("%d-%m-%Y") + " " + time.strftime("%X")
return response.generate_response(
'notify_alarm',
diff --git a/osm_mon/tests/unit/core/test_common_db_client.py b/osm_mon/tests/unit/core/test_common_db_client.py
index 7102226..b982bca 100644
--- a/osm_mon/tests/unit/core/test_common_db_client.py
+++ b/osm_mon/tests/unit/core/test_common_db_client.py
@@ -172,8 +172,9 @@
alarm.uuid = '1'
common_db_client = CommonDbClient(self.config)
common_db_client.create_alarm(alarm)
- create.assert_called_with('alarms', {'tags': {}, 'threshold': 50.0, 'metric': 'metric', 'severity': 'severity',
- 'statistic': 'statistic', 'name': 'name', 'uuid': '1'})
+ create.assert_called_with('alarms', {'tags': {}, 'threshold': 50.0, 'metric': 'metric',
+ 'severity': 'severity', 'statistic': 'statistic',
+ 'name': 'name', 'operation': 'operation', 'uuid': '1'})
@mock.patch.object(dbmongo.DbMongo, "db_connect", mock.Mock())
@mock.patch.object(dbmongo.DbMongo, "del_one")