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):