Module: check_mk
Branch: master
Commit: 9618096bc0a0cff956728696ba31b15e640b3a71
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9618096bc0a0cf…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jul 3 09:58:18 2013 +0200
Added webservice to trigger userdb syncrhonizations from external
---
web/htdocs/userdb.py | 13 ++++++++++++-
web/plugins/pages/shipped.py | 2 ++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/userdb.py b/web/htdocs/userdb.py
index 25d06da..b7f1f16 100644
--- a/web/htdocs/userdb.py
+++ b/web/htdocs/userdb.py
@@ -524,7 +524,7 @@ def hook_login(username, password):
# Is called on:
# a) before rendering the user management page in WATO
# b) a user is created during login (only for this user)
-def hook_sync(connector_id = None, add_to_changelog = False, only_username = None):
+def hook_sync(connector_id = None, add_to_changelog = False, only_username = None,
raise_exc = False):
if connector_id:
connectors = [ get_connector(connector_id) ]
else:
@@ -537,6 +537,8 @@ def hook_sync(connector_id = None, add_to_changelog = False,
only_username = Non
try:
handler(add_to_changelog, only_username)
except MKLDAPException, e:
+ if raise_exc:
+ raise
if config.debug:
import traceback
html.show_error(
@@ -550,6 +552,8 @@ def hook_sync(connector_id = None, add_to_changelog = False,
only_username = Non
)
no_errors = False
except:
+ if raise_exc:
+ raise
import traceback
html.show_error(
"<h3>" + _("Error executing sync hook") +
"</h3>"
@@ -614,3 +618,10 @@ def hook_page():
(connector['id'], traceback.format_exc()))
general_page_hook()
+
+def ajax_sync():
+ try:
+ hook_sync(add_to_changelog = False, raise_exc = True)
+ html.write('OK')
+ except Exception, e:
+ html.write('ERROR %s' % e)
diff --git a/web/plugins/pages/shipped.py b/web/plugins/pages/shipped.py
index e470577..523e92d 100644
--- a/web/plugins/pages/shipped.py
+++ b/web/plugins/pages/shipped.py
@@ -38,6 +38,7 @@ import dashboard
import login
import help
import bi
+import userdb
# map URLs to page rendering functions
@@ -78,5 +79,6 @@ pagehandlers.update({
"dashlet_pnpgraph" : dashboard.dashlet_pnpgraph,
"dashlet_nodata" : dashboard.dashlet_nodata,
"bi_availability" : bi.page_availability,
+ "ajax_userdb_sync" : userdb.ajax_sync,
})