Module: check_mk
Branch: master
Commit: c3672721a862184ab81be80692d6d0fa783a05a7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3672721a86218…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 11 09:52:36 2017 +0200
4958 FIX Group changes are added only to affected sites
Changes for edited groups (of hosts, services or contacts) are not
added to all sites anymore. Instead only the sites of the associated
customers get the change now.
Change-Id: I6e6d78e45e815f7d1ae432af192f0e9fb3c8778c
---
.werks/4958 | 13 +++++++++++++
web/htdocs/watolib.py | 20 ++++++++++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/.werks/4958 b/.werks/4958
new file mode 100644
index 0000000..bf07120
--- /dev/null
+++ b/.werks/4958
@@ -0,0 +1,13 @@
+Title: Group changes are added only to affected sites
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cme
+State: unknown
+Version: 1.5.0i1
+Date: 1499759323
+
+Changes for edited groups (of hosts, services or contacts) are not
+added to all sites anymore. Instead only the sites of the associated
+customers get the change now.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index a6ef26a..eab4cbc 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -8251,7 +8251,7 @@ def add_group(name, group_type, extra_info):
raise MKUserError("name", _("Sorry, there is already a group with
that name"))
_set_group(all_groups, group_type, name, extra_info)
- add_change("edit-%sgroups" % group_type, _("Create new %s group
%s") % (group_type, name))
+ add_group_change(extra_info, "edit-%sgroups" % group_type, _("Create
new %s group %s") % (group_type, name))
def edit_group(name, group_type, extra_info):
@@ -8263,7 +8263,7 @@ def edit_group(name, group_type, extra_info):
raise MKUserError("name", _("Unknown group: %s") % name)
_set_group(all_groups, group_type, name, extra_info)
- add_change("edit-%sgroups" % group_type, _("Updated properties of %s
group %s") % (group_type, name))
+ add_group_change(extra_info, "edit-%sgroups" % group_type, _("Updated
properties of %s group %s") % (group_type, name))
def delete_group(name, group_type):
@@ -8275,17 +8275,25 @@ def delete_group(name, group_type):
if name not in groups:
raise MKUserError(None, _("Unknown %s group: %s") % (group_type,
name))
-
# Check if still used
usages = find_usages_of_group(name, group_type)
if usages:
raise MKUserError(None, _("Unable to delete group. It is still in
use"))
-
# Delete group
- del groups[name]
+ group = groups.pop(name)
save_group_information(all_groups)
- add_change("edit-%sgroups", _("Deleted %s group %s") %
(group_type, name))
+ add_group_change(group, "edit-%sgroups", _("Deleted %s group %s")
% (group_type, name))
+
+
+# TODO: Consolidate all group change related functions in a class that can be overriden
+# by the CME code for better encapsulation.
+def add_group_change(group, action_name, text):
+ group_sites = None
+ if cmk.is_managed_edition() and not managed.is_global(group["customer"]):
+ group_sites = managed.get_sites_of_customer(group["customer"])
+
+ add_change(action_name, text, sites=group_sites)
def save_group_information(all_groups, custom_default_config_dir = None):