Module: check_mk
Branch: master
Commit: 2911038148e907a05697e1b0e182ea85ffbf0741
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2911038148e907…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed May 23 19:11:17 2018 +0200
Cleanup event_match_contacts in events.py
Change-Id: I6f7622988f3f9b95db4691594138708828e5b1b2
---
cmk_base/events.py | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/cmk_base/events.py b/cmk_base/events.py
index 7b5a509..d6bf254 100644
--- a/cmk_base/events.py
+++ b/cmk_base/events.py
@@ -562,20 +562,22 @@ def event_match_exclude_servicegroups(rule, context, is_regex = False):
def event_match_contacts(rule, context):
- if "match_contacts" in rule:
- required_contacts = rule["match_contacts"]
- contacts_text = context["CONTACTS"]
- if not contacts_text:
- return "The object has no contact, but %s is required" % (
- " or ".join(required_contacts))
-
- contacts = contacts_text.split(",")
- for contact in required_contacts:
- if contact in contacts:
- return
+ if "match_contacts" not in rule:
+ return
+
+ required_contacts = rule["match_contacts"]
+ contacts_text = context["CONTACTS"]
+ if not contacts_text:
+ return "The object has no contact, but %s is required" % (
+ " or ".join(required_contacts))
+
+ contacts = contacts_text.split(",")
+ for contact in required_contacts:
+ if contact in contacts:
+ return
- return "The object has the contacts %s, but %s is required" % (
- contacts_text, " or ".join(required_contacts))
+ return "The object has the contacts %s, but %s is required" % (
+ contacts_text, " or ".join(required_contacts))
def event_match_contactgroups(rule, context):
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):