Module: check_mk
Branch: master
Commit: 6d1b67706953b19f1f053ab55d287a2bedff0c47
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6d1b67706953b1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 1 09:22:10 2017 +0100
4421 FIX Host rename created a "parent rename" change for each existing host
When renaming a host via WATO, this created a change for each existing host. In
large installations this lead to a performance issue.
Change-Id: Ifa07bb44f65ba93e47230b9aa1cbf233770f283d
---
.werks/4421 | 12 ++++++++++++
web/htdocs/watolib.py | 19 ++++++++++++++-----
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/.werks/4421 b/.werks/4421
new file mode 100644
index 0000000..0c849a0
--- /dev/null
+++ b/.werks/4421
@@ -0,0 +1,12 @@
+Title: Host rename created a "parent rename" change for each existing host
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1488356473
+
+When renaming a host via WATO, this created a change for each existing host. In
+large installations this lead to a performance issue.
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 06ae353..ce332ed 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -1867,12 +1867,15 @@ class Folder(BaseFolder):
# Must not fail because of auth problems. Auth is check at the
# actually renamed host.
changed = rename_host_in_list(self._attributes["parents"], oldname,
newname)
- add_change("rename-parent",
- _("Renamed parent (set in folder) from %s to %s") % (self.path(),
oldname, newname),
+ if not changed:
+ return False
+
+ add_change("rename-parent", _("Renamed parent (set in folder) from
%s to %s") %
+ (self.path(), oldname, newname),
obj=self, sites=self.all_site_ids())
self.save_hosts()
self.save()
- return changed
+ return True
def rewrite_hosts_files(self):
@@ -2433,19 +2436,25 @@ class Host(WithPermissionsAndAttributes):
# on the renamed host must be sufficient. If we would
# fail here we would leave an inconsistent state
changed = rename_host_in_list(self._cluster_nodes, oldname, newname)
+ if not changed:
+ return False
+
add_change("rename-node", _("Renamed cluster node from %s into
%s.") % (oldname, newname),
obj=self, sites=[self.site_id()])
self.folder().save_hosts()
- return changed
+ return True
def rename_parent(self, oldname, newname):
# Same is with rename_cluster_node()
changed = rename_host_in_list(self._attributes["parents"], oldname,
newname)
+ if not changed:
+ return False
+
add_change("rename-parent", _("Renamed parent from %s into
%s.") % (oldname, newname),
obj=self, sites=[self.site_id()])
self.folder().save_hosts()
- return changed
+ return True
def rename(self, new_name):