Skip to content
Snippets Groups Projects
Commit 0c476c43 authored by Rajmund Hruška's avatar Rajmund Hruška
Browse files

Feature: Report extra detectors. (Redmine issue: #7577)

parent 4c0f3e18
No related branches found
No related tags found
No related merge requests found
...@@ -219,7 +219,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript): ...@@ -219,7 +219,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
:return: Structure containing information about changes. :return: Structure containing information about changes.
:rtype: dict :rtype: dict
""" """
result = {'create': [], 'delete': {}, 'update': {}} result = {'create': [], 'delete': [], 'update': {}}
det_db = {} det_db = {}
det_file = self.c(self.CONFIG_DETECTORS_FILE) det_file = self.c(self.CONFIG_DETECTORS_FILE)
...@@ -235,6 +235,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript): ...@@ -235,6 +235,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
det_db[detector.name] = detector det_db[detector.name] = detector
self._detectors_create_missing(det_db, det_file_data, det_file_type, result, status_only) self._detectors_create_missing(det_db, det_file_data, det_file_type, result, status_only)
self._detectors_report_extra(det_db, det_file_data, det_file_type, result, status_only)
return result return result
def _load_detectors_file(self, detectors_file): def _load_detectors_file(self, detectors_file):
...@@ -302,3 +303,23 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript): ...@@ -302,3 +303,23 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
self.logger.warning("'%s' Creating new detector.", gkey) self.logger.warning("'%s' Creating new detector.", gkey)
self.sqlservice.session.add(sqldet) self.sqlservice.session.add(sqldet)
self.sqlservice.session.commit() self.sqlservice.session.commit()
def _detectors_report_extra(self, det_db, det_file_data, det_file_type, result, status_only):
"""
Report extra detectors from database.
:param dict det_db: Detectors loaded from the database.
:param dict det_file_data: Detectors loaded from the reference detectors file.
:param str det_file_type: Source of the detectors in the reference detectors file.
:param dict result: Structure containing processing log, will be appended to script runlog.
:param bool status_only: Do not actually perform any database operations, just report status.
"""
for detector_name in sorted(det_db.keys()):
det = det_db[detector_name]
# For deletion consider only detectors with the same origin (source) as
# the loaded detectors file.
if det.source == det_file_type and detector_name not in det_file_data:
detkey = '{}::{}'.format(det.name, det.source)
result['delete'].append(detkey)
self.logger.warning("'%s' Detector was not found in the loaded detectors file, consider deletion.", detkey)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment