Module: check_mk
Branch: master
Commit: e8ee23c0b50c0a70409deaa60777ac2c437fe0df
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e8ee23c0b50c0a…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Sep 12 16:59:30 2016 +0200
3873 BI: now rules can easily be copied and deactivate temporarily
---
.werks/3873 | 9 +++++++++
ChangeLog | 1 +
web/htdocs/bi.py | 2 ++
web/plugins/wato/bi.py | 28 +++++++++++++++++++++++++---
4 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/.werks/3873 b/.werks/3873
new file mode 100644
index 0000000..92cd80d
--- /dev/null
+++ b/.werks/3873
@@ -0,0 +1,9 @@
+Title: BI: now rules can easily be copied and deactivate temporarily
+Level: 1
+Component: bi
+Compatible: compat
+Version: 1.4.0i1
+Date: 1473692330
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 5e01fa7..4653504 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -625,6 +625,7 @@
* 3396 Change default setting of Precompile aggregations on demand to ON now...
* 3449 The host alias can now be used in BI aggregates...
* 3546 Drastically sped up response time on querying single aggregations...
+ * 3873 BI: now rules can easily be copied and deactivate temporarily
* 3247 FIX: Do not allow multiple BI aggregates with the same title...
* 3232 FIX: BI: Only querying site of host for specific host status info...
* 3291 FIX: Improved error handling when searching for BI aggregations with invalid
regex
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index a3e1b47..b5ea624 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -492,6 +492,8 @@ def compile_rule_node(aggr_type, calllist, lvl):
"There is no rule named <tt>%s</tt>. Available are:
<tt>%s</tt>") %
(rulename, "</tt>,
<tt>".join(config.aggregation_rules.keys())))
rule = config.aggregation_rules[rulename]
+ if rule.get("disabled", False):
+ return []
# Execute FOREACH: iterate over matching hosts/services.
# Create an argument list where $1$, $2$, ... are
diff --git a/web/plugins/wato/bi.py b/web/plugins/wato/bi.py
index 5b8dcf9..40708fe 100644
--- a/web/plugins/wato/bi.py
+++ b/web/plugins/wato/bi.py
@@ -1154,14 +1154,26 @@ class ModeBIRules(ModeBI):
if not only_unused or refs == 0:
table.row()
table.cell(_("Actions"), css="buttons")
+
edit_url = self.url_to_pack([("mode",
"bi_edit_rule"), ("id", ruleid)])
html.icon_button(edit_url, _("Edit this rule"),
"edit")
+
+ clone_url = self.url_to_pack([("mode",
"bi_edit_rule"), ("clone", ruleid)])
+ html.icon_button(clone_url, _("Create a copy of this rule"),
"clone")
+
if rule_refs == 0:
tree_url = html.makeuri([("mode",
"bi_rule_tree"), ("id", ruleid)])
html.icon_button(tree_url, _("This is a top-level rule. Show
rule tree"), "bitree")
if refs == 0:
delete_url = html.makeactionuri_contextless([("mode",
"bi_rules"), ("_del_rule", ruleid), ("pack",
self._pack_id)])
html.icon_button(delete_url, _("Delete this rule"),
"delete")
+
+ table.cell("", css="narrow")
+ if rule.get("disabled"):
+ html.icon(_("This rule is currently disabled and will not be
applied"), "disabled")
+ else:
+ html.empty_icon_button()
+
table.cell(_("Level"), level or "",
css="number")
table.cell(_("ID"), '<a
href="%s">%s</a>' % (edit_url, ruleid))
table.cell(_("Parameters"), "
".join(rule["params"]))
@@ -1375,7 +1387,11 @@ class ModeBIEditRule(ModeBI):
def page(self):
if self._new:
- value = {}
+ cloneid = html.var("clone")
+ if cloneid:
+ value = self._pack["rules"][cloneid]
+ else:
+ value = {}
else:
value = self._pack["rules"][self._ruleid]
@@ -1405,7 +1421,6 @@ class ModeBIEditRule(ModeBI):
size = 64,
),
),
-
( "comment",
TextUnicode(
title = _("Comment"),
@@ -1433,6 +1448,13 @@ class ModeBIEditRule(ModeBI):
)
)
),
+ ( "disabled",
+ Checkbox(
+ title = _("Rule activation"),
+ help = _("Disabled rules are kept in the configuration but are
not applied."),
+ label = _("do not apply this rule"),
+ )
+ ),
( "aggregation",
CascadingDropdown(
title = _("Aggregation Function"),
@@ -1471,7 +1493,7 @@ class ModeBIEditRule(ModeBI):
render = "form",
elements = elements,
headers = [
- ( _("General Properties"), [ "id",
"title", "comment", "params" ]),
+ ( _("General Properties"), [ "id",
"title", "comment", "params", "disabled" ]),
( _("Child Node Generation"), [ "nodes" ] ),
( _("Aggregation Function"), [ "aggregation" ], ),
]