Module: check_mk
Branch: master
Commit: 1eb9b174a2a988bba8058b0f78b8d552ff95df93
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1eb9b174a2a988…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Jun 13 10:39:46 2016 +0200
3542 FIX WATO Web API: fixed exception when WATO Git is activated
---
.werks/3542 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 10 +++++-----
web/htdocs/watolib.py | 7 +++++++
web/htdocs/webapi.py | 4 ++++
5 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/.werks/3542 b/.werks/3542
new file mode 100644
index 0000000..9cf2e28
--- /dev/null
+++ b/.werks/3542
@@ -0,0 +1,10 @@
+Title: WATO Web API: fixed exception when WATO Git is activated
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.9i1
+Date: 1465807142
+Class: fix
+
+The Web API was unusable with activated WATO Git.
+
diff --git a/ChangeLog b/ChangeLog
index 8c84965..dcf1a4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -431,6 +431,7 @@
* 3583 FIX: Fixed loosing some services after saving services in WATO...
* 3588 FIX: BI aggregation: Fixed folding of tag groups in aggregation rules using
host/service searches
* 3620 FIX: Do not longer put SNMP MIB files into WATO snapshots...
+ * 3542 FIX: WATO Web API: fixed exception when WATO Git is activated...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 279fdbb..a5338bd5 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -103,12 +103,8 @@ wato_styles = [ "pages", "wato",
"status" ]
def init_wato_datastructures():
- if config.wato_use_git:
- prepare_git_commit()
-
create_sample_config() # if called for the very first time!
- declare_host_tag_attributes() # create attributes out of tag definitions
- declare_site_attribute() # create attribute for distributed WATO
+ init_watolib_datastructures()
#.
@@ -14164,6 +14160,10 @@ def create_sample_config():
or os.path.exists(wato_root_dir + "global.mk"):
return
+ # Just in case. If any of the following functions try to write Git messages
+ if config.wato_use_git:
+ prepare_git_commit()
+
# Global configuration settings
save_configuration_settings(
{
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index dc1f1dd..64ecd27 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -92,6 +92,13 @@ def initialize_before_loading_plugins():
global backup_domains
backup_domains = {}
+def init_watolib_datastructures():
+ if config.wato_use_git:
+ prepare_git_commit()
+
+ declare_host_tag_attributes() # create attributes out of tag definitions
+ declare_site_attribute() # create attribute for distributed WATO
+
#.
# .--Constants-----------------------------------------------------------.
# | ____ _ _ |
diff --git a/web/htdocs/webapi.py b/web/htdocs/webapi.py
index 200c110..422d321 100644
--- a/web/htdocs/webapi.py
+++ b/web/htdocs/webapi.py
@@ -65,10 +65,14 @@ def page_api():
config.need_permission("wato.use")
config.need_permission("wato.api_allowed")
+
action = html.var('action')
if action not in api_actions:
raise MKUserError(None, "Unknown API action %s" %
html.attrencode(action))
+ # Initialize host and site attributes
+ init_watolib_datastructures()
+
# Prepare request_object
# Most of the time the request is given as json
# However, the plugin may have an own mechanism to interpret the request