Skip to content

Commit

Permalink
add trap desc mapping and change alert_lists sequence_number to match…
Browse files Browse the repository at this point in the history
…_key (#543)

* add trap desc mapping and change alert_lists sequence_number to match_key

* add trap desc mapping and change alert_lists sequence_number to match_key

* add trap desc mapping and add match_key to unity alert

* add trap desc mapping and add match_key to unity alert

* add trap desc mapping and add match_key to unity alert

Co-authored-by: tanjy <306848916@qq.com>
  • Loading branch information
tanjiangyu-ghca and jiangyutan authored Apr 2, 2021
1 parent 41765b5 commit 65fff0f
Show file tree
Hide file tree
Showing 3 changed files with 3,498 additions and 8 deletions.
14 changes: 11 additions & 3 deletions delfin/drivers/dell_emc/unity/alert_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from delfin import exception
from delfin.common import alert_util
from delfin.common import constants
from delfin.drivers.dell_emc.unity import consts
from delfin.i18n import _

LOG = log.getLogger(__name__)
Expand Down Expand Up @@ -68,16 +69,21 @@ def parse_alert(context, alert):
try:
alert_model = dict()
alert_model['alert_id'] = alert.get(AlertHandler.OID_SYMPTOMID)
alert_model['alert_name'] = alert.get(AlertHandler.OID_COMPONENT)
trap_map_desc = consts.TRAP_DESC.get(
alert.get(AlertHandler.OID_SYMPTOMID))
if trap_map_desc:
alert_desc = trap_map_desc[2]
else:
alert_desc = alert.get(AlertHandler.OID_SYMPTOMTEXT)
alert_model['alert_name'] = alert.get(AlertHandler.OID_SYMPTOMTEXT)
alert_model['severity'] = AlertHandler.TRAP_LEVEL_MAP.get(
alert.get(AlertHandler.OID_SEVERITY),
constants.Severity.INFORMATIONAL)
alert_model['category'] = constants.Category.FAULT
alert_model['type'] = constants.EventType.EQUIPMENT_ALARM
occur_time = int(time.time()) * AlertHandler.SECONDS_TO_MS
alert_model['occur_time'] = occur_time
alert_model['description'] = alert.get(
AlertHandler.OID_SYMPTOMTEXT)
alert_model['description'] = alert_desc
alert_model['resource_type'] = constants.DEFAULT_RESOURCE_TYPE
alert_model['location'] = alert.get(AlertHandler.OID_NODE)
alert_model['match_key'] = hashlib.md5(alert.get(
Expand Down Expand Up @@ -126,6 +132,8 @@ def parse_queried_alerts(self, alert_model_list, alert_dict, query_para):
alert_model['resource_type'] = resource_type
alert_model['location'] = location
alert_model_list.append(alert_model)
alert_model['match_key'] = hashlib.md5(
content.get('message').encode()).hexdigest()
except Exception as e:
LOG.error(e)
err_msg = "Failed to build alert model as some attributes " \
Expand Down
Loading

0 comments on commit 65fff0f

Please sign in to comment.