Module: check_mk
Branch: master
Commit: 07bf3ee77021f575314604a5f9764eac5bf7d70a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07bf3ee77021f5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 3 14:23:08 2019 +0200
Fix initial service discovery after host creation
When a host was created the GUI did a service discovery in previous
versions, at least for non SNMP devices. This is now done for all
hosts again.
CMK-1851
Change-Id: I4204179dce9e82bdfb5663e81d2db4e62656d7d1
---
cmk/gui/wato/__init__.py | 1 -
cmk/gui/wato/pages/hosts.py | 17 ++++++++++++-----
cmk/gui/wato/pages/services.py | 9 ++++-----
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/cmk/gui/wato/__init__.py b/cmk/gui/wato/__init__.py
index 6d4a4d2..beea148 100644
--- a/cmk/gui/wato/__init__.py
+++ b/cmk/gui/wato/__init__.py
@@ -245,7 +245,6 @@ from cmk.gui.wato.pages.rulesets import (
from cmk.gui.wato.pages.search import ModeSearch
from cmk.gui.wato.pages.services import (
ModeDiscovery,
- ModeFirstDiscovery,
ModeAjaxExecuteCheck,
)
from cmk.gui.wato.pages.sites import (
diff --git a/cmk/gui/wato/pages/hosts.py b/cmk/gui/wato/pages/hosts.py
index 5463e7f..f50ac8f 100644
--- a/cmk/gui/wato/pages/hosts.py
+++ b/cmk/gui/wato/pages/hosts.py
@@ -41,7 +41,7 @@ from cmk.gui.plugins.wato.utils.context_buttons import
host_status_button
from cmk.gui.globals import html
from cmk.gui.i18n import _
-from cmk.gui.exceptions import MKUserError, MKAuthException, MKGeneralException
+from cmk.gui.exceptions import MKUserError, MKAuthException, MKGeneralException,
HTTPRedirect
from cmk.gui.valuespec import ListOfStrings, Hostname
from cmk.gui.wato.pages.folders import delete_host_after_confirm
@@ -327,19 +327,26 @@ class CreateHostMode(HostMode):
self._host = watolib.Folder.current().host(hostname)
+ inventory_url = watolib.folder_preserving_link([
+ ("mode", "inventory"),
+ ("host", self._host.name()),
+ ("_scan", "1"),
+ ])
+
if not self._host.is_ping_host():
create_msg = _('Successfully created the host. Now you should do a '
'<a href="%s">service discovery</a>
in order to auto-configure '
- 'all services to be checked on this host.') % \
- watolib.folder_preserving_link([("mode",
"inventory"), ("host", self._host.name())])
+ 'all services to be checked on this host.') %
inventory_url
else:
create_msg = None
if html.request.var("services"):
- return "inventory"
- elif html.request.var("diag_host"):
+ raise HTTPRedirect(inventory_url)
+
+ if html.request.var("diag_host"):
html.request.set_var("_try", "1")
return "diag_host", create_msg
+
return "folder", create_msg
def _show_host_name(self):
diff --git a/cmk/gui/wato/pages/services.py b/cmk/gui/wato/pages/services.py
index 605cf60..65fedb6 100644
--- a/cmk/gui/wato/pages/services.py
+++ b/cmk/gui/wato/pages/services.py
@@ -178,15 +178,18 @@ class ModeDiscovery(WatoMode):
self._host.need_permission("read")
+ action = DiscoveryAction.NONE
if config.user.may("wato.services"):
show_checkboxes = config.user.load_file("discovery_checkboxes",
False)
+ if html.request.var("_scan") == "1":
+ action = DiscoveryAction.SCAN
else:
show_checkboxes = False
show_parameters = not config.user.load_file("parameter_column", False)
self._options = DiscoveryOptions(
- action=DiscoveryAction.NONE,
+ action=action,
show_checkboxes=show_checkboxes,
show_parameters=show_parameters,
ignore_errors=bool(html.request.var("ignoreerrors")),
@@ -1565,10 +1568,6 @@ class DiscoveryPageRenderer(object):
]
-class ModeFirstDiscovery(ModeDiscovery):
- pass
-
-
@page_registry.register_page("wato_ajax_execute_check")
class ModeAjaxExecuteCheck(AjaxPage):
def _from_vars(self):