Module: check_mk
Branch: master
Commit: 1cb47c0532c2a084c7c48492a54478144f4426de
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1cb47c0532c2a0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Apr 19 10:59:41 2016 +0200
Marking agents need to be baked when changing agent related rules
---
web/htdocs/wato.py | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 451978a..40f14c4 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1782,8 +1782,9 @@ def rename_host_in_rulesets(folder, oldname, newname):
rules[nr] = newrule
changed_rulesets.append(varname)
changed = True
+
if changed:
- save_rulesets(folder, rulesets)
+ save_changed_ruleset(varname, folder, rulesets)
folder.mark_hosts_dirty()
for subfolder in folder.subfolders().values():
@@ -11701,6 +11702,9 @@ def change_host_tags_in_rules(folder, operations, mode):
ruleset[nr] = construct_rule(rulespec, value, tag_specs, host_list,
item_list, rule_options)
need_save = True
+ if has_agent_bakery() and is_affecting_baked_agents(varname):
+ need_to_bake_agents()
+
rules_to_delete = list(rules_to_delete)
rules_to_delete.sort()
for nr in rules_to_delete[::-1]:
@@ -12229,7 +12233,7 @@ def mode_edit_ruleset(phase):
% (rulenr + 1, rule_folder.alias_path()))
if c:
del rules[rulenr]
- save_rulesets(rule_folder, rulesets)
+ save_changed_ruleset(varname, rule_folder, rulesets)
rule_folder.mark_hosts_dirty()
log_pending(AFFECTED, None, "edit-ruleset",
_("Deleted rule in ruleset '%s'") %
rulespec["title"])
@@ -12243,7 +12247,7 @@ def mode_edit_ruleset(phase):
if not html.check_transaction():
return None # browser reload
rules[rulenr:rulenr] = [rules[rulenr]]
- save_rulesets(rule_folder, rulesets)
+ save_changed_ruleset(varname, rule_folder, rulesets)
rule_folder.mark_hosts_dirty()
log_pending(AFFECTED, None, "edit-ruleset",
@@ -12263,7 +12267,7 @@ def mode_edit_ruleset(phase):
rules.insert(0, rule)
else:
rules.append(rule)
- save_rulesets(rule_folder, rulesets)
+ save_changed_ruleset(varname, rule_folder, rulesets)
rule_folder.mark_hosts_dirty()
log_pending(AFFECTED, None, "edit-ruleset",
_("Changed order of rules in ruleset %s") %
rulespec["title"])
@@ -12455,6 +12459,12 @@ def show_rule_in_table(rulespec, tag_specs, host_list, item_list,
varname, value
html.write(html.attrencode(desc))
+def save_changed_ruleset(varname, rule_folder, rulesets):
+ if has_agent_bakery() and is_affecting_baked_agents(varname):
+ need_to_bake_agents()
+ save_rulesets(rule_folder, rulesets)
+
+
def create_rule(rulespec, hostname=None, item=NO_ITEM):
new_rule = []
valuespec = rulespec["valuespec"]
@@ -12846,7 +12856,7 @@ def mode_edit_rule(phase, new = False):
rules.append(rule)
else:
rules[rulenr] = rule
- save_rulesets(folder, rulesets)
+ save_changed_ruleset(varname, folder, rulesets)
folder.mark_hosts_dirty()
if new:
@@ -12858,11 +12868,11 @@ def mode_edit_rule(phase, new = False):
else: # Move rule to new folder
if not new:
del rules[rulenr]
- save_rulesets(folder, rulesets)
+ save_changed_ruleset(varname, folder, rulesets)
rulesets = load_rulesets(new_rule_folder)
rules = rulesets.setdefault(varname, [])
rules.append(rule)
- save_rulesets(new_rule_folder, rulesets)
+ save_changed_ruleset(varname, new_rule_folder, rulesets)
folder.mark_hosts_dirty()
new_rule_folder.mark_hosts_dirty()
log_pending(AFFECTED, None, "edit-rule", _("Changed
properties of rule %s, moved rule from "
@@ -14106,7 +14116,7 @@ def create_sample_config():
config.wato_aux_tags = wato_aux_tags
# Initial baking of agents (when bakery is available)
- if 'bake_agents' in globals():
+ if has_agent_bakery():
try:
bake_agents()
except:
@@ -14117,6 +14127,10 @@ def create_sample_config():
import werks
werks.acknowledge_all_werks()
+
+def has_agent_bakery():
+ return 'bake_agents' in globals()
+
#.
# .--Pattern Editor------------------------------------------------------.
# | ____ _ _ _____ _ _ _ |