Module: check_mk
Branch: master
Commit: 3ef5b51a4032b68b7703d3fa083aafdc10295bb1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3ef5b51a4032b6…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Sep 11 15:48:07 2018 +0200
6495 FIX Bulk discovery: "Include subfolders" does not make sense for a
selection of hosts
Change-Id: I5e86c86d70b15dc7bf2fda612db3b02c21b3fd49
---
.werks/6495 | 15 +++++++++++++++
cmk/gui/plugins/wato/utils/__init__.py | 24 +++++++++++++-----------
cmk/gui/wato/__init__.py | 14 +++++++++++---
3 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/.werks/6495 b/.werks/6495
new file mode 100644
index 0000000..eea854c
--- /dev/null
+++ b/.werks/6495
@@ -0,0 +1,15 @@
+Title: Bulk discovery: "Include subfolders" does not make sense for a selection
of hosts
+Level: 1
+Component: wato
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1536673221
+Class: fix
+
+A selection of hosts is already given in the following situations:
+<ul>
+<li>in the current folder below <i>Selected hosts:
Discovery</i>,</li>
+<li>Below <i>Bulk import</i> a automatic service discovery for
+imported/selected hosts can be executed</li>
+</ul>
diff --git a/cmk/gui/plugins/wato/utils/__init__.py
b/cmk/gui/plugins/wato/utils/__init__.py
index e5334ff..fdab5c4 100644
--- a/cmk/gui/plugins/wato/utils/__init__.py
+++ b/cmk/gui/plugins/wato/utils/__init__.py
@@ -178,12 +178,23 @@ def monitoring_macro_help():
"the macro <tt>$_HOSTFOO$</tt> being replaced with
<tt>bar</tt> ")
-def vs_bulk_discovery(render_form=False):
+def vs_bulk_discovery(render_form=False, include_subfolders=True):
if render_form:
render = "form"
else:
render = None
+ if include_subfolders:
+ selection_elements = [Checkbox(label = _("Include all subfolders"),
default_value = True)]
+ else:
+ selection_elements = []
+
+ selection_elements += [
+ Checkbox(label = _("Only include hosts that failed on previous
discovery"), default_value = False),
+ Checkbox(label = _("Only include hosts with a failed discovery check"),
default_value = False),
+ Checkbox(label = _("Exclude hosts where the agent is unreachable"),
default_value = False),
+ ]
+
return Dictionary(
title = _("Bulk discovery"),
render = render,
@@ -201,16 +212,7 @@ def vs_bulk_discovery(render_form=False):
)),
("selection", Tuple(
title = _("Selection"),
- elements = [
- Checkbox(label = _("Include all subfolders"),
- default_value = True),
- Checkbox(label = _("Only include hosts that failed on previous
discovery"),
- default_value = False),
- Checkbox(label = _("Only include hosts with a failed discovery
check"),
- default_value = False),
- Checkbox(label = _("Exclude hosts where the agent is
unreachable"),
- default_value = False),
- ]
+ elements = selection_elements
)),
("performance", Tuple(
title = _("Performance options"),
diff --git a/cmk/gui/wato/__init__.py b/cmk/gui/wato/__init__.py
index 0d57e58..5608a27 100644
--- a/cmk/gui/wato/__init__.py
+++ b/cmk/gui/wato/__init__.py
@@ -895,8 +895,10 @@ class ModeFolder(WatoMode):
if config.user.may("wato.edit_hosts"):
html.button("_bulk_edit", _("Edit"))
html.button("_bulk_cleanup", _("Cleanup"))
+
if config.user.may("wato.services"):
html.button("_bulk_inventory", _("Discovery"))
+
if not self._folder.locked_hosts():
if config.user.may("wato.parentscan"):
html.button("_parentscan", _("Parentscan"))
@@ -4656,10 +4658,16 @@ class ModeBulkDiscovery(WatoMode):
html.begin_form("bulkinventory", method="POST")
html.hidden_fields()
- vs = cmk.gui.plugins.wato.vs_bulk_discovery(render_form=True)
-
msgs = []
- if not self._all:
+ if self._all:
+ vs = cmk.gui.plugins.wato.vs_bulk_discovery(render_form=True)
+ else:
+ # "Include subfolders" does not make sense for a selection of
hosts
+ # which is already given in the following situations:
+ # - in the current folder below 'Selected hosts: Discovery'
+ # - Below 'Bulk import' a automatic service discovery for
+ # imported/selected hosts can be executed
+ vs = cmk.gui.plugins.wato.vs_bulk_discovery(render_form=True,
include_subfolders=False)
msgs.append(_("You have selected <b>%d</b> hosts for
bulk discovery.") % len(hosts_to_discover))
selection = self._bulk_discovery_params["selection"]
self._bulk_discovery_params["selection"] = [False] +
list(selection[1:])