Skip to content

Commit

Permalink
vue: migrated a few HostAddress attributes
Browse files Browse the repository at this point in the history
Change-Id: I44c2df46176837acb56b725eb60a84a4b43cf542
  • Loading branch information
schnetzzz committed Aug 24, 2024
1 parent 3758282 commit cd3d5b8
Showing 1 changed file with 81 additions and 1 deletion.
82 changes: 81 additions & 1 deletion cmk/gui/watolib/builtin_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from cmk.gui import fields as gui_fields
from cmk.gui import hooks, userdb
from cmk.gui.exceptions import MKUserError
from cmk.gui.form_specs.generators.host_address import create_host_address
from cmk.gui.form_specs.generators.setup_site_choice import create_setup_site_choice
from cmk.gui.htmllib.generator import HTMLWriter
from cmk.gui.i18n import _
Expand Down Expand Up @@ -74,7 +75,13 @@
import cmk.fields.validators
from cmk import fields
from cmk.rulesets.v1 import Help, Message, Title
from cmk.rulesets.v1.form_specs import InvalidElementMode, InvalidElementValidator, SingleChoice
from cmk.rulesets.v1.form_specs import (
InvalidElementMode,
InvalidElementValidator,
List,
SingleChoice,
String,
)


class HostAttributeAlias(ABCHostAttributeNagiosText):
Expand Down Expand Up @@ -152,6 +159,27 @@ def valuespec(self) -> ValueSpec:
allow_ipv6_address=False,
)

def form_spec(self) -> String:
return create_host_address(
title=Title("IPv4 address"),
help_text=Help(
"Specify an explicit IP address or resolvable DNS name here, if "
"the host name is not resolvable via <tt>/etc/hosts</tt> or DNS. "
"If you do not set this attribute, host name resolution will be "
"performed when the configuration is enabled. Checkmk's "
"built-in DNS cache is enabled by default in the global "
"configuration to speed up the activation process. The cache is "
"normally updated daily by a cron job. You can manually update "
"the cache with the <tt>cmk -v --update-dns-cache</tt> "
"command.<br><br><b>Dynamic IP addresses only:</b><br>If you "
"enter a DNS name here, the DNS resolution will be performed "
"each time the host is checked. Checkmk's DNS cache is "
"<b>NOT</b> queried."
),
allow_empty=False,
allow_ipv6_address=False,
)

def openapi_field(self) -> gui_fields.Field:
return fields.String(
description="An IPv4 address.",
Expand Down Expand Up @@ -202,6 +230,27 @@ def valuespec(self) -> ValueSpec:
allow_ipv4_address=False,
)

def form_spec(self) -> String:
return create_host_address(
title=Title("IPv6 address"),
help_text=Help(
"Specify an explicit IPv6 address or resolvable DNS name here, if "
"the host name is not resolvable via <tt>/etc/hosts</tt> or DNS. "
"If you do not set this attribute, host name resolution will be "
"performed when the configuration is enabled. Checkmk's "
"built-in DNS cache is enabled by default in the global "
"configuration to speed up the activation process. The cache is "
"normally updated daily by a cron job. You can manually update "
"the cache with the <tt>cmk -v --update-dns-cache</tt> "
"command.<br><br><b>Dynamic IP addresses only:</b><br>If you "
"enter a DNS name here, the DNS resolution will be performed "
"each time the host is checked. Checkmk's DNS cache is "
"<b>NOT</b> queried."
),
allow_empty=False,
allow_ipv4_address=False,
)

def openapi_field(self) -> gui_fields.Field:
return fields.String(
description="An IPv6 address.",
Expand Down Expand Up @@ -250,6 +299,16 @@ def valuespec(self) -> ValueSpec:
),
)

def form_spec(self) -> List:
return List[str](
title=Title("Additional IPv4 addresses"),
help_text=Help(
"Specify additional IPv4 addresses here. These can be used in "
"active checks such as ICMP."
),
element_template=create_host_address(allow_empty=False, allow_ipv6_address=False),
)

def openapi_field(self) -> gui_fields.Field:
return fields.List(
fields.String(
Expand Down Expand Up @@ -300,6 +359,16 @@ def valuespec(self) -> ValueSpec:
),
)

def form_spec(self) -> List:
return List[str](
title=Title("Additional IPv6 addresses"),
help_text=Help(
"Specify additional IPv6 addresses here. These can be used in "
"active checks such as ICMP."
),
element_template=create_host_address(allow_empty=False, allow_ipv4_address=False),
)

def openapi_field(self) -> gui_fields.Field:
return fields.List(
fields.String(
Expand Down Expand Up @@ -861,6 +930,17 @@ def valuespec(self) -> ValueSpec:
allow_empty=False,
)

def form_spec(self) -> String:
return create_host_address(
title=Title("Address"),
help_text=Help(
"Address (IPv4 or IPv6) or dns name under which the "
"management board can be reached. If this is not set, "
"the same address as that of the host will be used."
),
allow_empty=False,
)

def openapi_field(self) -> gui_fields.Field:
return fields.String(
description="Address (IPv4, IPv6 or host name) under which the management board can be reached.",
Expand Down

0 comments on commit cd3d5b8

Please sign in to comment.