Module: check_mk
Branch: master
Commit: aaa4c1be38c38f4ebfd2e8ec75a10ac96c0bf967
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aaa4c1be38c38f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 5 10:38:12 2017 +0200
4605 FIX Bakery: Fixed marking agents to be build after changing agent related rulesets
Change-Id: I8ab640988cbe3ca0a50ce69f791df01a4aa6298f
---
.werks/4605 | 11 +++++++++++
web/htdocs/wato.py | 4 +---
web/htdocs/watolib.py | 25 +++++++++++++++++++------
3 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/.werks/4605 b/.werks/4605
new file mode 100644
index 0000000..5e372d3
--- /dev/null
+++ b/.werks/4605
@@ -0,0 +1,11 @@
+Title: Bakery: Fixed marking agents to be build after changing agent related rulesets
+Level: 1
+Component: agents
+Class: fix
+Compatible: compat
+Edition: cee
+State: unknown
+Version: 1.5.0i1
+Date: 1493973466
+
+
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 75c6ac0..c49df35 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -13554,10 +13554,8 @@ class ModeEditRule(WatoMode):
def _save_rule(self):
# Just editing without moving to other folder
+ self._ruleset.edit_rule(self._rule)
self._rulesets.save()
- add_change("edit-rule", _("Changed properties of rule
\"%s\" in folder \"%s\"") %
- (self._ruleset.title(), self._folder.alias_path()),
- sites=self._folder.all_site_ids())
def _success_message(self):
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 1073b42..ec684c9 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -243,9 +243,10 @@ def add_change(action_name, text, obj=None, add_user=True,
need_sync=None,
need_sidebar_reload()
# On each change to the Check_MK configuration mark the agents to be rebuild
- if has_agent_bakery():
- # pylint: disable=undefined-variable
- need_to_bake_agents()
+ # TODO: Really? Why?
+ #if has_agent_bakery():
+ # import agent_bakery
+ # agent_bakery.mark_need_to_bake_agents()
ActivateChangesWriter().add_change(action_name, text, obj, add_user,
need_sync, need_restart, domains, sites)
@@ -6706,6 +6707,13 @@ class Ruleset(object):
return self._rules[folder.path()][rule_index]
+ def edit_rule(self, rule):
+ add_change("edit-rule", _("Changed properties of rule
\"%s\" in folder \"%s\"") %
+ (self.title(), rule.folder.alias_path()),
+ sites=rule.folder.all_site_ids())
+ self._on_change()
+
+
def delete_rule(self, rule):
self._rules[rule.folder.path()].remove(rule)
add_change("edit-ruleset", _("Deleted rule in ruleset
'%s'") % self.title(),
@@ -6806,8 +6814,9 @@ class Ruleset(object):
def _on_change(self):
- if has_agent_bakery() and is_affecting_baked_agents(self.name): # pylint:
disable=undefined-variable
- need_to_bake_agents() # pylint: disable=undefined-variable
+ if has_agent_bakery():
+ import agent_bakery
+ agent_bakery.ruleset_changed(self.name)
# Returns the outcoming value or None and a list of matching rules. These are pairs
@@ -7805,7 +7814,11 @@ def edit_users(changed_users):
def has_agent_bakery():
- return 'bake_agents' in globals()
+ try:
+ import agent_bakery
+ return True
+ except ImportError:
+ return False
def get_folder_cgconf_from_attributes(attributes):