Could not import CheckParameterRuleSpecWithItem

CMK: 2.1.0p16 cre
OS version: Raspbian GNU/Linux 11 (bullseye)

Error: Broken UI extensions
CRIT: Loading “/omd/sites/test/local/share/check_mk/web/plugins/wato/exists.py” failed: cannot import name ‘CheckParameterRuleSpecWithItem’ from ‘cmk.gui.plugins.wato’ (unknown location) (!!)

I dont understand why i get this Error. I did it like in the docs for creating plugins.

File:

#!/usr/bin/python
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
    Dictionary,
    Integer,
    TextAscii,
    DropdownChoice
)
from cmk.gui.plugins.wato import (
    CheckParameterRuleSpecWithItem,
    rulespec_registry,
    RulespecGroupCheckParametersOperatingSystem,
)

def _item_valuespec_exists():
    return TextAscii(title=_("absolute Path"))

def _parameter_valuespec_exists():
    return Dictionary(
        elements=[
            ("shouldCrit", DropDownChoice(
                title = _("Throw critical if not found otherwise it throws warning"),
                help = _("default is Yes"),
                choices = [
                    (False, _("No")),
                    (True, _("Yes")),
                ],
                default_value= "yes"
            )),

        ]
    )


rulespec_registry.register(
    CheckParameterRulespecWithItem(
        check_group_name="exists",
        group=RulespecGroupParametersOperatingSystem,
        item_spec=_item_valuespec_exists,
        match_type="dict",
        parameter_valuespec=_parameter_valuespec_exists,
        title=lambda: _("Parameter for checking if Files/Folder exists")
    )
)

@TheEggi98 looks like there are some typos in there

the S in Spec needs to be lower case

from cmk.gui.plugins.wato import (
    # CheckParameterRuleSpecWithItem,
    CheckParameterRulespecWithItem,
    rulespec_registry,

The D in Down needs to be lower case

elements=[
            # ("shouldCrit", DropDownChoice(
            ("shouldCrit", DropdownChoice(
                title = _("Throw critical if 

the Check in RulespecGroupParametersOperatingSystem is missing

 check_group_name="exists",
        # group=RulespecGroupParametersOperatingSystem,
        group=RulespecGroupCheckParametersOperatingSystem,
2 Likes