Skip to content

Commit 96c4091

Browse files
MakeilaLunJenkins
authored andcommitted
port Livestatus proxy and Service discovery's 5 variables to FormSpec
CMK-36197 Change-Id: Id680ce142607d696edb4e93bb3b574585cfa6448
1 parent 147934b commit 96c4091

1 file changed

Lines changed: 25 additions & 22 deletions

File tree

cmk/gui/wato/_check_mk_configuration.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from cmk.checkengine.snmplib import SNMPBackendEnum # astrein: disable=cmk-module-layer-violation
2121
from cmk.gui.config import active_config
2222
from cmk.gui.exceptions import MKConfigError, MKUserError
23+
from cmk.gui.form_specs.unstable import OptionalChoice
2324
from cmk.gui.groups import GroupName
2425
from cmk.gui.http import request
2526
from cmk.gui.i18n import _, _l, get_languages
@@ -130,8 +131,9 @@
130131
from cmk.gui.watolib.utils import site_neutral_path
131132
from cmk.ruleset_matcher.definition import RuleGroup
132133
from cmk.ruleset_matcher.tags import TagGroup, TagGroupID, TagID
134+
from cmk.rulesets.internal.form_specs import SingleChoiceElementExtended, SingleChoiceExtended
133135
from cmk.rulesets.v1 import form_specs as fs
134-
from cmk.rulesets.v1 import Help, Title
136+
from cmk.rulesets.v1 import Help, Label, Title
135137

136138
from ._check_plugin_selection import CheckPluginSelection
137139
from ._group_selection import (
@@ -3374,15 +3376,9 @@ def _validate_proxies(value: Sequence[Mapping[str, object]], varprefix: str) ->
33743376
group=ConfigVariableGroupServiceDiscovery,
33753377
primary_domain=ConfigDomainCore,
33763378
ident="inventory_check_interval",
3377-
valuespec=lambda context: Optional(
3378-
valuespec=Integer(
3379-
title=_("Perform service discovery check every"),
3380-
unit=_("minutes"),
3381-
minvalue=1,
3382-
default_value=720,
3383-
),
3384-
title=_("Enable regular service discovery checks (deprecated)"),
3385-
help=_(
3379+
form_spec=lambda context: OptionalChoice(
3380+
title=Title("Enable regular service discovery checks (deprecated)"),
3381+
help_text=Help(
33863382
"If enabled, Checkmk will create one additional service per host "
33873383
"that does a regular check, if the service discovery would find new services "
33883384
"currently un-monitored. <b>Note:</b> This option is deprecated and has been "
@@ -3392,38 +3388,45 @@ def _validate_proxies(value: Sequence[Mapping[str, object]], varprefix: str) ->
33923388
"settings done here."
33933389
)
33943390
% {"url": "wato.py?mode=edit_ruleset&varname=periodic_discovery"},
3391+
parameter_form=fs.Integer(
3392+
title=Title("Perform service discovery check every"),
3393+
unit_symbol=_("minutes"),
3394+
prefill=fs.DefaultValue(720),
3395+
custom_validate=[fs.validators.NumberInRange(min_value=1)],
3396+
),
33953397
),
33963398
)
33973399

33983400
ConfigVariableInventoryCheckSeverity = ConfigVariable(
33993401
group=ConfigVariableGroupServiceDiscovery,
34003402
primary_domain=ConfigDomainCore,
34013403
ident="inventory_check_severity",
3402-
valuespec=lambda context: DropdownChoice(
3403-
title=_("Severity of failed service discovery check"),
3404-
help=_(
3404+
form_spec=lambda context: SingleChoiceExtended[int](
3405+
title=Title("Severity of failed service discovery check"),
3406+
help_text=Help(
34053407
"Please select which alarm state the service discovery check services "
34063408
"shall assume in case that un-monitored services are found."
34073409
),
3408-
choices=[
3409-
(0, _("OK - do not alert, just display")),
3410-
(1, _("Warning")),
3411-
(2, _("Critical")),
3412-
(3, _("Unknown")),
3410+
elements=[
3411+
SingleChoiceElementExtended(name=0, title=Title("OK - do not alert, just display")),
3412+
SingleChoiceElementExtended(name=1, title=Title("Warning")),
3413+
SingleChoiceElementExtended(name=2, title=Title("Critical")),
3414+
SingleChoiceElementExtended(name=3, title=Title("Unknown")),
34133415
],
3416+
prefill=fs.DefaultValue(0),
34143417
),
34153418
)
34163419

34173420
ConfigVariableInventoryCheckAutotrigger = ConfigVariable(
34183421
group=ConfigVariableGroupServiceDiscovery,
34193422
primary_domain=ConfigDomainCore,
34203423
ident="inventory_check_autotrigger",
3421-
valuespec=lambda context: Checkbox(
3422-
title=_("Service discovery triggers service discovery check"),
3423-
label=_(
3424+
form_spec=lambda context: fs.BooleanChoice(
3425+
title=Title("Service discovery triggers service discovery check"),
3426+
label=Label(
34243427
"Automatically schedule service discovery check after service configuration changes"
34253428
),
3426-
help=_(
3429+
help_text=Help(
34273430
"When this option is enabled then after each change of the service "
34283431
"configuration of a host via Setup - may it be via manual changes or a bulk "
34293432
"discovery - the service discovery check is automatically rescheduled in order "

0 commit comments

Comments
 (0)