How do I migrate a ruleset where one of the parameters is a Tuple() with two TextAscii() fields for comparing with a version number?
{"version": ('2.3.0', '2.2.0')}
I tried with this specification:
def _valuespec_test_string_levels():
return Dictionary(
title=Title("TEST String Levels"),
elements={
"version": DictElement(
parameter_form=SimpleLevels(
title=Title("Version"),
form_spec_template=String(),
level_direction=LevelDirection.LOWER,
prefill_fixed_levels=InputHint(("2.3.0p31", "2.3.0b1")),
)
)
}
)
rule_spec_test_string_levels = CheckParameters(
name="test_string_levels",
topic=Topic.APPLICATIONS,
parameter_form=_valuespec_test_string_levels,
title=Title("TEST String Levels"),
condition=HostCondition(),
)
But I get the error message:
Internal error: cannot access local variable 'prefill_value' where it is not associated with a value
This is a test with a completely new ruleset specification. The next step would be to write a migration function, but first the spec must work.
The old code looked like this:
def _parameter_valuespec_test_string_levels():
return Dictionary(
title = _("TEST String Levels"),
elements = [
('version', Tuple(
title = _("Version"),
elements = [
TextAscii(title = _("Warning below"), default_value = "2.3.0p31"),
TextAscii(title = _("Critical below"), default_value = "2.3.0b1"),
]
),
],
)