V2.0.0 check API - error - default discovery parameters must be dict

Hi folks,

I am currently migrating my extensions from v1.6 API to v2.0 API due to the fact, that the host_extra_conf() function is not supported anymore.

According to How to make a plugin V2 compatible (-> host_name) - #2 by r.sander the use of own WATO rule during discovery now should be defined using discover_ruleset_name and discovery_ruleset_type parameters during registration command.

So I have adapted my plugin as described according to PRO TIP PRO TIP: Migrate plugin vnx_quotas · tribe29/checkmk@b428616 · GitHub

My discovery rule returns a WATO-like object like ListOf(Tuple(TextAscii(),TextAscii())) so it returns a list.

So i went with the following register command parameters:

register.check_plugin(
    name="sadmin_versions",
    sections=['sadmin'],
    service_name="SW version of %s",
    discovery_function=discovery_sadmin_versions,
    discovery_default_parameters=[],
    discovery_ruleset_name="inventory_sadmin_versions_rules",
    discovery_ruleset_type=register.RuleSetType.ALL,
...
)

But when I activate those changes, I get the following exception during discovery:
image

My WATO rule deliveres a list of tuples, so the default value (which is mandatory by the API) must be an empty list.

When i change the discovery_default_parameters value to an empty dict => {} i get the following error during a reload:

How must I specify my discovery rule correctly, so it can be used by the discovery function?

Thank you

Best Regards

Markus

You need to rewrite your WATO rule so that it results in a Dict(). Make it a one element dictionary with the ListOf() as the only non-optional element.

Ok, but then the existing configuration will not be compatible with the new valuespec, so all rules have to be deleted and inserted manually. Or is there any possibility to merge existing rules to the new valuespec?

Do you know the reason, why only dict is allowed?

There is a Transform() class for the WATO rules to do that.

thank you very much. I will have a look.

Have a nice weekend!