diff --git a/cmk/utils/agent_registration.py b/cmk/utils/agent_registration.py index 8a017eefaee..5443a037d6a 100644 --- a/cmk/utils/agent_registration.py +++ b/cmk/utils/agent_registration.py @@ -9,7 +9,7 @@ from collections.abc import Container, Iterator, Mapping, Sequence from os.path import relpath from pathlib import Path -from typing import Any, NamedTuple +from typing import Any, Final from uuid import UUID import cmk.utils.paths @@ -43,17 +43,12 @@ def connection_mode_from_host_config( ) -class UUIDLink(NamedTuple): - source: Path - target: Path - - @property - def uuid(self) -> UUID: - return UUID(self.source.name) - - @property - def hostname(self) -> HostName: - return HostName(self.target.name) +class UUIDLink: + def __init__(self, *, source: Path, target: Path) -> None: + self.source: Final = source + self.target: Final = target + self.uuid: Final = UUID(self.source.name) + self.hostname: Final = HostName(self.target.name) def unlink(self) -> None: self.source.unlink(missing_ok=True) diff --git a/tests/unit/cmk/utils/test_agent_registration.py b/tests/unit/cmk/utils/test_agent_registration.py index b9c87395d65..0b160fe4a0d 100644 --- a/tests/unit/cmk/utils/test_agent_registration.py +++ b/tests/unit/cmk/utils/test_agent_registration.py @@ -29,7 +29,10 @@ class TestUUIDLink: @pytest.fixture def link(self, tmp_path: Path) -> UUIDLink: - return UUIDLink(tmp_path / "59e631e9-de89-40d6-9662-ba54569a24fb", tmp_path / "hostname") + return UUIDLink( + source=tmp_path / "59e631e9-de89-40d6-9662-ba54569a24fb", + target=tmp_path / "hostname", + ) def test_uuid(self, link: UUIDLink) -> None: assert isinstance(link.uuid, UUID)