fix(monitor): modify notify alertInfo and alertOk detach resource

1.修复报警信息中>等被转义的问题
2.针对:host_raid.adapter和smart_device.exit_status
  只能出现alerting和nodata
两种报警状态。在queryCondition的查询逻辑下,nodata情况也进行detach操作
3.修复报警记录中报警策略翻译异常的问题
This commit is contained in:
zhaoxiangchun
2020-11-23 21:32:15 +08:00
parent 8e50c94614
commit 68dfa8a8c8
8 changed files with 81 additions and 46 deletions
+7 -1
View File
@@ -91,7 +91,9 @@ func getTemplate(ctx context.Context, topic string, contType string, channel npk
if err != nil {
return nil, err
}
tmp, err := template.New(key).Parse(string(cont))
tmp := template.New(key)
tmp.Funcs(template.FuncMap{"unescaped": unescaped})
tmp, err = tmp.Parse(string(cont))
if err != nil {
return nil, err
}
@@ -100,6 +102,10 @@ func getTemplate(ctx context.Context, topic string, contType string, channel npk
return templatesTable[key], nil
}
func unescaped(str string) template.HTML {
return template.HTML(str)
}
func getContent(ctx context.Context, topic string, contType string, channel npk.TNotifyChannel, data jsonutils.JSONObject) (string, error) {
if channel == npk.NotifyByWebhook {
return "", nil