def _get_parameters_from_request(self, request): """Get and verify discovery parameters from the request The API call only makes a part of all bulk discovery parameters configurable because the API call currently only operates on a list of given hostnames where a lot of the GUI options are not relevant for. For a consistent parameter handling we use the valuespec here.""" params = copy.deepcopy(config.bulk_discovery_default_settings) # type: Dict[str, Any] params["mode"] = request.get("mode", params["mode"]) params["performance"] = ( request.get("use_cache", params["performance"][0]), request.get("do_scan", params["performance"][1]), request.get("bulk_size", params["performance"][2]), ) params["error_handling"] = request.get("ignore_single_check_errors", params["error_handling"]) vs_bulk_discovery().validate_value(params, "") return ( params["mode"], params["performance"][0], params["performance"][1], params["performance"][2], params["error_handling"], )
def _show_start_form(self): html.begin_form("bulkinventory", method="POST") msgs = [] if self._all: vs = 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 = vs_bulk_discovery(render_form=True, include_subfolders=False) msgs.append( _("You have selected <b>%d</b> hosts for bulk discovery.") % len(self._get_hosts_to_discover())) # The cast is needed for the moment, because mypy does not understand our data structure here selection = cast(Tuple[bool, bool, bool, bool], self._bulk_discovery_params["selection"]) self._bulk_discovery_params["selection"] = [False] + list( selection[1:]) msgs.append( _("The Checkmk discovery will automatically find and configure services " "to be checked on your hosts and may also discover host labels.") ) html.open_p() html.write_text(" ".join(msgs)) vs.render_input("bulkinventory", self._bulk_discovery_params) forms.end() html.button("_start", _("Start")) html.hidden_fields() html.end_form()
def _get_parameters_from_request( self, request ) -> Tuple[DiscoveryMode, DoFullScan, BulkSize, IgnoreErrors]: """Get and verify discovery parameters from the request The API call only makes a part of all bulk discovery parameters configurable because the API call currently only operates on a list of given hostnames where a lot of the GUI options are not relevant for. For a consistent parameter handling we use the valuespec here.""" params: Dict[str, Any] = copy.deepcopy( active_config.bulk_discovery_default_settings) params["mode"] = request.get("mode", params["mode"]) params["performance"] = ( request.get("do_scan", params["performance"][0]), int(request.get("bulk_size", params["performance"][1])), ) params["error_handling"] = request.get("ignore_single_check_errors", params["error_handling"]) vs_bulk_discovery().validate_value(params, "") return ( DiscoveryMode(params["mode"]), DoFullScan(params["performance"][0]), BulkSize(params["performance"][1]), IgnoreErrors(params["error_handling"]), )
def _get_bulk_discovery_params(self): self._bulk_discovery_params = copy.deepcopy(config.bulk_discovery_default_settings) if self._start: # Only do this when the start form has been submitted bulk_discover_params = vs_bulk_discovery().from_html_vars("bulkinventory") vs_bulk_discovery().validate_value(bulk_discover_params, "bulkinventory") self._bulk_discovery_params.update(bulk_discover_params) self._recurse, self._only_failed, self._only_failed_invcheck, \ self._only_ok_agent = self._bulk_discovery_params["selection"] self._use_cache, self._do_scan, self._bulk_size = \ self._bulk_discovery_params["performance"] self._mode = self._bulk_discovery_params["mode"] self._error_handling = self._bulk_discovery_params["error_handling"]
def _get_bulk_discovery_params(self): self._bulk_discovery_params = copy.deepcopy(config.bulk_discovery_default_settings) if self._start: # Only do this when the start form has been submitted bulk_discover_params = vs_bulk_discovery().from_html_vars("bulkinventory") vs_bulk_discovery().validate_value(bulk_discover_params, "bulkinventory") self._bulk_discovery_params.update(bulk_discover_params) # The cast is needed for the moment, because mypy does not understand our data structure here (self._recurse, self._only_failed, self._only_failed_invcheck, self._only_ok_agent) = cast( Tuple[bool, bool, bool, bool], self._bulk_discovery_params["selection"] ) self._do_scan, self._bulk_size = self._get_performance_params() self._mode = self._bulk_discovery_params["mode"] self._error_handling = self._bulk_discovery_params["error_handling"]