[checkmk-commits] Check_MK Git: check_mk: WATO: fixed some internal reference problems on setting host attributes

Andreas Boesl ab at mathias-kettner.de
Mon Aug 25 19:12:38 CEST 2014


Module: check_mk
Branch: master
Commit: bdede7113e27cb8b162d1ea23dba94c5f0fe0ce2
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bdede7113e27cb8b162d1ea23dba94c5f0fe0ce2

Author: Andreas Boesl <ab at mathias-kettner.de>
Date:   Mon Aug 25 19:12:28 2014 +0200

WATO: fixed some internal reference problems on setting host attributes

---

 web/htdocs/wato.py |   30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1901872..405139d 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -16851,18 +16851,34 @@ def update_host_attributes(host, attr = {}, unset_attr = []):
 def set_host_attributes(host, attributes):
     hostname = host[".name"]
 
+    folder_path = host[".folder"][".path"]
+
+    the_folder = g_folders[folder_path]
+    load_hosts(the_folder)
+
     # The site attribute might change. In that case also
     # the old site of the host must be marked dirty.
-    mark_affected_sites_dirty(host[".folder"], hostname)
+    mark_affected_sites_dirty(the_folder, hostname)
+
+    the_folder[".hosts"][hostname] = attributes
+    save_hosts(the_folder)
 
-    host[".folder"][".hosts"][hostname] = attributes
-    save_hosts(host[".folder"])
+    the_folder = reload_folder(the_folder)
+    reload_hosts(the_folder)
+
+    if g_folder:
+        set_current_folder(g_folders[g_folder[".path"]])
 
     log_pending(AFFECTED, hostname, "edit-host", _("edited properties of host [%s]") % hostname)
+    mark_affected_sites_dirty(the_folder, hostname)
+
+    call_hook_hosts_changed(the_folder)
 
-    reload_hosts(host[".folder"])
-    mark_affected_sites_dirty(host[".folder"], hostname)
-    call_hook_hosts_changed(host[".folder"])
+    # TODO: find a better solution
+    # Some hooks kill our reloaded folder... do it again...
+    the_folder = g_folders[folder_path]
+    the_folder = reload_folder(the_folder)
+    reload_hosts(the_folder)
 
 # Deletes host from given folder
 def delete_host(host):
@@ -16976,7 +16992,7 @@ class API:
     def __get_valid_api_host_attributes(self, attributes):
         result = {}
 
-        host_attribute_names = map(lambda (x, y): x.name(), host_attributes)
+        host_attribute_names = map(lambda (x, y): x.name(), host_attributes) + ["inventory_failed"]
 
         for key, value in attributes.items():
             if key in host_attribute_names:



More information about the checkmk-commits mailing list