Skip to content

Commit

Permalink
Fix wato rulespec in CMK 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
apoxa committed Jul 3, 2023
1 parent eb9e858 commit 7f5a6ba
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 50 deletions.
6 changes: 3 additions & 3 deletions package
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"name": "Check_NSX",
"title": "Checkmk extension for NSX-T 3.x",
"version": "0.4.10",
"version.min_required": "2.0.0",
"version.packaged": "2.0.0",
"version": "0.4.11",
"version.min_required": "2.2.0",
"version.packaged": "2.2.0",
}
90 changes: 43 additions & 47 deletions web/plugins/wato/nsx_datasource_programs.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,69 @@
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-

import cmk.gui.watolib as watolib
from cmk.gui.i18n import _
from cmk.gui.plugins.wato.special_agents.common import RulespecGroupVMCloudContainer
from cmk.gui.plugins.wato import (
HostRulespec,
IndividualOrStoredPassword,
rulespec_registry,
HostRulespec,
)
from cmk.gui.plugins.wato.datasource_programs import RulespecGroupDatasourcePrograms
from cmk.gui.valuespec import Dictionary, DropdownChoice, TextAscii, Transform
from cmk.gui.i18n import _
from cmk.gui.valuespec import (
Dictionary,
DropdownChoice,
TextAscii,
)
from cmk.gui.watolib.rulespecs import Rulespec


def _factory_default_special_agents_nsx():
# No default, do not use setting if no rule matches
return watolib.Rulespec.FACTORY_DEFAULT_UNUSED


def _transform_agent_nsx(params):
params.setdefault("cert", False)

return params
return Rulespec.FACTORY_DEFAULT_UNUSED


def _valuespec_special_agents_nsx():
return Transform(
Dictionary(
title=_("Check state of a NSX-T 3.x environment"),
help=_(
"This rule selects the VMWare NSX-T agent instead of the normal Check_MK Agent2 and allows"
"monitoring of NSX-T environment via NSX-T Manager API. You can configure your connection "
"settings here."
),
elements=[
(
"user",
TextAscii(
title=_("Username"),
allow_empty=False,
),
return Dictionary(
title=_("Check state of a NSX-T 3.x environment"),
help=_(
"This rule selects the VMWare NSX-T agent instead of the normal Check_MK Agent2 and allows"
"monitoring of NSX-T environment via NSX-T Manager API. You can configure your connection "
"settings here."
),
elements=[
(
"user",
TextAscii(
title=_("Username"),
allow_empty=False,
),
(
"password",
IndividualOrStoredPassword(
title=_("Password"),
allow_empty=False,
),
),
(
"password",
IndividualOrStoredPassword(
title=_("Password"),
allow_empty=False,
),
(
"cert",
DropdownChoice(
title=_("SSL certificate checking"),
choices=[
(True, _("Activate")),
(False, _("Deactivated")),
],
),
),
(
"cert",
DropdownChoice(
title=_("SSL certificate checking"),
choices=[
(True, _("Activate")),
(False, _("Deactivated")),
],
default_value=False,
),
],
optional_keys=["cert"],
),
forth=_transform_agent_nsx,
),
],
optional_keys=["cert"],
)


rulespec_registry.register(
HostRulespec(
factory_default=_factory_default_special_agents_nsx(),
group=RulespecGroupDatasourcePrograms,
group=RulespecGroupVMCloudContainer,
name="special_agents:nsx",
valuespec=_valuespec_special_agents_nsx,
)
Expand Down

0 comments on commit 7f5a6ba

Please sign in to comment.