Module: check_mk
Branch: master
Commit: 15136a6f0ff8f53339af60c9ed91d1095f75da61
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=15136a6f0ff8f5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 17 11:15:20 2015 +0100
#2146 FIX In distributed environments user notification rules trigger a profile
synchronisation now
In previous versions the custom user notification rules were not synchronized to
remote sites in the moment the user changed his rules. An admin had to perform
a synchronisation via WATO to replicate these changes to the rules to the remote
sites for taking effect there.
Now, when a user changes his individual notification rules, a replication of
the updated user profile is triggered.
---
.werks/2146 | 16 ++++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 74 ++++++++++++++++++++++++++++++++++++++++++----------
3 files changed, 77 insertions(+), 14 deletions(-)
diff --git a/.werks/2146 b/.werks/2146
new file mode 100644
index 0000000..16b4917
--- /dev/null
+++ b/.werks/2146
@@ -0,0 +1,16 @@
+Title: In distributed environments user notification rules trigger a profile
synchronisation now
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1426587167
+
+In previous versions the custom user notification rules were not synchronized to
+remote sites in the moment the user changed his rules. An admin had to perform
+a synchronisation via WATO to replicate these changes to the rules to the remote
+sites for taking effect there.
+
+Now, when a user changes his individual notification rules, a replication of
+the updated user profile is triggered.
diff --git a/ChangeLog b/ChangeLog
index 3d78848..f1fbe7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -357,6 +357,7 @@
* 2084 FIX: Disabled notification for a user is now shown on profile page even when
not permitted to edit...
* 2045 FIX: Avoid fetching SNMP data when showing service list in WATO - unless Full
Scan is pressed
* 2047 FIX: Allow overriding existing WATO rules by own files in local/ hierarchy...
+ * 2146 FIX: In distributed environments user notification rules trigger a profile
synchronisation now...
Notifications:
* 1662 notification plugin spectrum: finalized script. now able to handle host
notications
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index c6365df..dc927bc 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9087,6 +9087,8 @@ def render_bulks(only_ripe):
# Similar like mode_notifications, but just for the user specific notification table
def mode_user_notifications(phase, profilemode):
+ global notification_rule_start_async_repl
+
if profilemode:
userid = config.user_id
title = _("Your personal notification rules")
@@ -9120,10 +9122,18 @@ def mode_user_notifications(phase, profilemode):
_("Do you really want to delete the notification rule
<b>%d</b> <i>%s</i>?" %
(nr, rule.get("description",""))))
if c:
- log_pending(SYNC, None, "notification-delete-user-rule",
_("Deleted notification rule %d of user %s") %
- (nr, userid))
del rules[nr]
userdb.save_users(users)
+
+ log_what = "notification-delete-user-rule"
+ log_text = _("Deleted notification rule %d of user %s") % (nr,
userid)
+
+ notification_rule_start_async_repl = False
+ if profilemode and is_distributed():
+ notification_rule_start_async_repl = True
+ log_audit(None, log_what, log_text)
+ else:
+ log_pending(SYNC, None, log_what, log_text)
elif c == False:
return ""
else:
@@ -9137,15 +9147,31 @@ def mode_user_notifications(phase, profilemode):
del rules[from_pos] # make to_pos now match!
rules[to_pos:to_pos] = [rule]
userdb.save_users(users)
- log_pending(SYNC, None, "notification-move-user-rule",
_("Changed position of notification rule %d of user %s") %
- (from_pos, userid))
+
+ log_what = "notification-move-user-rule"
+ log_text = _("Changed position of notification rule %d of user
%s") % (from_pos, userid)
+
+ notification_rule_start_async_repl = False
+ if profilemode and is_distributed():
+ notification_rule_start_async_repl = True
+ log_audit(None, log_what, log_text)
+ else:
+ log_pending(SYNC, None, log_what, log_text)
return
+ if notification_rule_start_async_repl:
+ user_profile_async_replication_dialog()
+ notification_rule_start_async_repl = False
+ html.write('<h3>%s</h3>' % _('Notification Rules'))
+
rules = user.get("notification_rules", [])
render_notification_rules(rules, userid, profilemode = profilemode)
+notification_rule_start_async_repl = False
def mode_notification_rule(phase, profilemode):
+ global notification_rule_start_async_repl
+
edit_nr = int(html.var("edit", "-1"))
clone_nr = int(html.var("clone", "-1"))
if profilemode:
@@ -9215,9 +9241,20 @@ def mode_notification_rule(phase, profilemode):
save_notification_rules(rules)
if new:
- log_pending(SYNC, None, "new-notification-rule", _("Created
new notification rule") + suffix)
+ log_what = "new-notification-rule"
+ log_text = _("Created new notification rule") + suffix
+ else:
+ log_what = "edit-notification-rule"
+ log_text = _("Changed notification rule %d") % edit_nr + suffix
+
+ notification_rule_start_async_repl = False
+ if profilemode and is_distributed():
+ notification_rule_start_async_repl = True
+ log_audit(None, log_what, log_text)
+ return # don't redirect to other page
else:
- log_pending(SYNC, None, "edit-notification-rule", _("Changed
notification rule %d") % edit_nr + suffix)
+ log_pending(SYNC, None, log_what, log_text)
+
if profilemode:
return "user_notifications_p"
elif userid:
@@ -9225,6 +9262,10 @@ def mode_notification_rule(phase, profilemode):
else:
return "notifications"
+ if notification_rule_start_async_repl:
+ user_profile_async_replication_dialog()
+ notification_rule_start_async_repl = False
+ return
html.begin_form("rule", method = "POST")
vs.render_input("rule", rule)
@@ -15683,8 +15724,8 @@ def select_language(user):
'create you own translation, you find <a
href="%(url)s">documentation online</a>.') %
{ "url" :
"http://mathias-kettner.de/checkmk_multisite_i18n.html"} )
-def user_profile_async_replication_dialog():
- html.header(_('Replicate new Authentication Information'),
+def user_profile_async_replication_page():
+ html.header(_('Replicate new User Profile'),
javascripts = ['wato'],
stylesheets = ['check_mk', 'pages', 'wato',
'status'])
@@ -15692,14 +15733,20 @@ def user_profile_async_replication_dialog():
html.context_button(_('User Profile'), 'user_profile.py',
'back')
html.end_context_buttons()
+ user_profile_async_replication_dialog()
+
+ html.footer()
+
+
+def user_profile_async_replication_dialog():
sites = [(name, config.site(name)) for name in config.sitenames() ]
sort_sites(sites)
repstatus = load_replication_status()
- html.message(_('To make a login possible with your new credentials on all remote
sites, the '
- 'new login credentials need to be replicated to the remote sites.
This is done '
- 'on this page now. Each site is being represented by a single
image which is first '
- 'shown gray and then fills to green during
synchronisation.'))
+ html.message(_('For make your changes available on all remote sites, your user
profile needs '
+ 'to be replicated to the remote sites. This is done on this page
now. Each site '
+ 'is being represented by a single image which is first shown gray
and then fills '
+ 'to green during synchronisation.'))
html.write('<h3>%s</h3>' % _('Replication States'))
html.write('<div id="profile_repl">')
@@ -15741,7 +15788,6 @@ def user_profile_async_replication_dialog():
html.javascript('var g_num_replsites = %d;\n' % num_replsites)
html.write('</div>')
- html.footer()
def page_user_profile(change_pw=False):
@@ -15853,7 +15899,7 @@ def page_user_profile(change_pw=False):
# When in distributed setup, display the replication dialog instead of the normal
# profile edit dialog after changing the password.
if start_async_replication:
- user_profile_async_replication_dialog()
+ user_profile_async_replication_page()
return
if change_pw: