Module: check_mk
Branch: master
Commit: 8848efb8b55f7e0f208cb1631fadb558a6a83eb5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8848efb8b55f7e…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed May 23 18:50:07 2018 +0200
Cleanup event_match_contactgroups in events.py
Change-Id: Ib1e48c10ed3cf0441a4d3052c5b39273d3d027e4
---
cmk_base/events.py | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/cmk_base/events.py b/cmk_base/events.py
index 7766eae..7b5a509 100644
--- a/cmk_base/events.py
+++ b/cmk_base/events.py
@@ -580,29 +580,25 @@ def event_match_contacts(rule, context):
def event_match_contactgroups(rule, context):
required_groups = rule.get("match_contactgroups")
+ if required_groups is None:
+ return
+
if context["WHAT"] == "SERVICE":
cgn = context.get("SERVICECONTACTGROUPNAMES")
else:
cgn = context.get("HOSTCONTACTGROUPNAMES")
- if required_groups != None:
- if cgn == None:
- #event_log("Warning: No information about contact groups in the context.
" \
- # "Seems that you don't use the Check_MK Microcore.
")
- return
-
- if cgn:
- contactgroups = cgn.split(",")
- else:
- return "The object is in no group, but %s is required" % (
- " or ".join(required_groups))
+ if cgn is None:
+ return
+ if not cgn:
+ return "The object is in no group, but %s is required" % (" or
".join(required_groups))
- for group in required_groups:
- if group in contactgroups:
- return
+ contactgroups = cgn.split(",")
+ for group in required_groups:
+ if group in contactgroups:
+ return
- return "The object is only in the groups %s, but %s is required" % (
- cgn, " or ".join(required_groups))
+ return "The object is only in the groups %s, but %s is required" % (cgn,
" or ".join(required_groups))
def event_match_hostgroups(rule, context):