Module: check_mk
Branch: master
Commit: c985c37379b864ad503e519744cd3daabe3c3f01
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c985c37379b864…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Apr 9 15:02:28 2018 +0200
5833 FIX Fixed handling of 'acknowledged' parameter of the EC's UPDATE
command
Previously, the 'acknowledged' parameter of the EC's UPDATE command was
processed after the event was already (partially) updated. When the
'acknowledged' parameter was missing or not an integer, this behavior was
confusing and could e.g. lead to missing history entries.
Now all parameters are checked before the event is modified, so no partial
updates happen. Furthermore, the 'acknowledged' parameter is optional now,
restoring the previous accidental behavior in a clean way.
Change-Id: I29e44d2c54b6b01ceaad8415c5012b5206cbc50d
---
.werks/5833 | 17 +++++++++++++++++
cmk/ec/main.py | 9 ++++++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.werks/5833 b/.werks/5833
new file mode 100644
index 0000000..1e65f88
--- /dev/null
+++ b/.werks/5833
@@ -0,0 +1,17 @@
+Title: Fixed handling of 'acknowledged' parameter of the EC's UPDATE command
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1523278661
+Class: fix
+
+Previously, the 'acknowledged' parameter of the EC's UPDATE command was
+processed after the event was already (partially) updated. When the
+'acknowledged' parameter was missing or not an integer, this behavior was
+confusing and could e.g. lead to missing history entries.
+
+Now all parameters are checked before the event is modified, so no partial
+updates happen. Furthermore, the 'acknowledged' parameter is optional now,
+restoring the previous accidental behavior in a clean way.
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index ed7ac4f..b5c4647 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -3756,13 +3756,16 @@ class StatusServer(ECServerThread):
event = self._event_status.event(int(event_id))
if not event:
raise MKClientError("No event with id %s" % event_id)
+ # Note the common practice: We validate parameters *before* doing any changes.
+ if acknowledged:
+ ack = int(acknowledged)
+ if ack and event["phase"] not in ["open",
"ack"]:
+ raise MKClientError("You cannot acknowledge an event that is not
open.")
+ event["phase"] = "ack" if ack else "open"
if comment:
event["comment"] = comment
if contact:
event["contact"] = contact
- if int(acknowledged) and event["phase"] not in ["open",
"ack"]:
- raise MKClientError("You cannot acknowledge an event that is not
open.")
- event["phase"] = int(acknowledged) and "ack" or
"open"
log_event_history(self.settings, self._config, self._table_events, event,
"UPDATE", user)
def handle_command_create(self, arguments):