added password store option for api-key

This commit is contained in:
mellis 2024-01-26 11:39:01 +01:00
parent f06a32bf80
commit 276e67d473
3 changed files with 17 additions and 12 deletions

View File

@ -6,6 +6,7 @@ import requests
import urllib3 import urllib3
import json import json
import os import os
import cmk.utils.password_store
from pprint import pprint from pprint import pprint
from requests.structures import CaseInsensitiveDict from requests.structures import CaseInsensitiveDict
from requests.auth import HTTPBasicAuth from requests.auth import HTTPBasicAuth
@ -391,6 +392,7 @@ def doCmkOutputDomains() -> None:
def main(): def main():
global debugLogFilename global debugLogFilename
cmk.utils.password_store.replace_passwords()
getOptions() getOptions()
# do some parameter checks # do some parameter checks
if (opt_hostname == ""): if (opt_hostname == ""):

View File

@ -1,7 +1,7 @@
def agent_mailcow_arguments(params, hostname, ipaddress): def agent_mailcow_arguments(params, hostname, ipaddress):
return [ return [
"--hostname", params["hostname"], "--hostname", params["hostname"],
"--apikey", params["apikey"], "--apikey", passwordstore_get_cmdline("%s", params["apikey"]),
"--port", params["port"], "--port", params["port"],
"--no-https", params["no_https"], "--no-https", params["no_https"],
"--no-cert-check", params["no_cert_check"], "--no-cert-check", params["no_cert_check"],

View File

@ -1,8 +1,4 @@
from cmk.gui.i18n import _ from cmk.gui.i18n import _
from cmk.gui.plugins.wato import (
CheckParameterRulespecWithItem,
rulespec_registry,
)
from cmk.gui.plugins.wato.special_agents.common import ( from cmk.gui.plugins.wato.special_agents.common import (
RulespecGroupDatasourceProgramsApps, RulespecGroupDatasourceProgramsApps,
@ -12,29 +8,36 @@ from cmk.gui.plugins.wato.special_agents.common import (
RulespecGroupDatasourceProgramsTesting, RulespecGroupDatasourceProgramsTesting,
) )
from cmk.gui.plugins.wato.utils import (
IndividualOrStoredPassword,
rulespec_registry,
CheckParameterRulespecWithItem,
CheckParameterRulespecWithoutItem,
HostRulespec,
Rulespec,
)
from cmk.gui.valuespec import ( from cmk.gui.valuespec import (
Dictionary, Dictionary,
ListChoice, ListChoice,
Checkbox, Checkbox,
TextAscii, TextAscii,
Password, Password,
NetworkPort,
Integer,
) )
from cmk.gui.plugins.wato import (
HostRulespec,
)
from cmk.gui.plugins.wato.datasource_programs import RulespecGroupDatasourceProgramsCustom
def _valuespec_special_agent_mailcow(): def _valuespec_special_agent_mailcow():
return Dictionary( return Dictionary(
title=_("Mailcow Server Information"), title=_("Mailcow Server Information"),
help = _("Checking Mailcow instances via API"), help = _("Checking Mailcow instances via API"),
elements=[ elements=[
("hostname", TextAscii(title=_("Hostname"), ("hostname", TextAscii(title=_("Hostname"),
size=32,
allow_empty=False, allow_empty=False,
help=_("Hostname of Mailcow server (bare FQDN or IP), mandatory"))), help=_("Hostname of Mailcow server (bare FQDN or IP), mandatory"))),
("apikey", TextAscii(title=_("API Key"), ("apikey", IndividualOrStoredPassword(title=_("API Key"),
size=32,
allow_empty=False, allow_empty=False,
help=_("API Key, mandatory"))), help=_("API Key, mandatory"))),
("port", TextAscii(title=_("Port"), ("port", TextAscii(title=_("Port"),