initial commit source files
This commit is contained in:
42
hal9002/server_side_calls/agent_hal9002.py
Normal file
42
hal9002/server_side_calls/agent_hal9002.py
Normal file
@@ -0,0 +1,42 @@
|
||||
"""HAL9002 parameter handling for the special agent"""
|
||||
|
||||
from collections.abc import Iterable
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from cmk.server_side_calls.v1 import (
|
||||
HostConfig,
|
||||
Secret,
|
||||
SpecialAgentCommand,
|
||||
SpecialAgentConfig,
|
||||
)
|
||||
|
||||
|
||||
class Hal9002Params(BaseModel):
|
||||
"""defines all needed parameters for the special agent"""
|
||||
|
||||
hostname: str | None = None
|
||||
username: str | None = None
|
||||
password: Secret | None = None
|
||||
|
||||
|
||||
def agent_hal9002_arguments(
|
||||
params: Hal9002Params, _host_config: HostConfig
|
||||
) -> Iterable[SpecialAgentCommand]:
|
||||
"""replaces the argument_thingy from the old API"""
|
||||
command_arguments: list[str | Secret] = []
|
||||
if params.hostname is not None:
|
||||
command_arguments += ["--hostname", params.hostname]
|
||||
if params.username is not None:
|
||||
command_arguments += ["--username", params.username]
|
||||
if params.password is not None:
|
||||
command_arguments += ["--password", params.password.unsafe()]
|
||||
yield SpecialAgentCommand(command_arguments=command_arguments)
|
||||
|
||||
|
||||
special_agent_hal9002 = SpecialAgentConfig(
|
||||
# name must be the filename of the executable for the special agent (without prefix)
|
||||
name="hal9002",
|
||||
parameter_parser=Hal9002Params.model_validate,
|
||||
commands_function=agent_hal9002_arguments,
|
||||
)
|
||||
Reference in New Issue
Block a user