#!/usr/bin/env python3 # # GUI configuration pages to set up inventorying and checks done by the CUCM # agent to CUCM. These two pages are for giving the agent the necessary details # to connect to CUCM (e.g. IP address, user, login, etc). # # Ideally, we'd have a single page to configure both the inventorying and # checks, since both contact the same CUCM instance. Unfortunately, I didn't # find a clean way to do it, so we're left with two identical GUI pages that # take identical information. At least we manage to share most of the code # here by taking a deep copy and modifying the title. import copy from cmk.gui.i18n import _ from cmk.gui.plugins.wato.utils import ( rulespec_registry, HostRulespec, RulespecGroupCheckParametersHardware ) from cmk.gui.plugins.wato.inventory import RulespecGroupInventory from cmk.gui.watolib.rulespecs import Rulespec from cmk.gui.valuespec import ( Dictionary, TextInput, Hostname, NetworkPort, Password, TextAscii, FixedValue ) # GUI config page for inventory. def _valuespec_special_agents_cucm_inv(): return Dictionary( title=_("CUCM inventory"), help=_(""), optional_keys=["port", "user", "password", "insecure"], elements=[ ( "instance", Hostname( title=_("Hostname"), help=_( "Host of CUCM host for query" ), allow_empty=False, ), ), ( "port", NetworkPort( title=_("Port"), help=_( "Port of CUCM host for query" ), minvalue=1, default_value=443, ), ), ( "user", TextInput( title=_("Username"), help=_( "Username used when querying CUCM" ), ), ), ( "password", Password( title=_("Password"), help=_( "Password used when querying CUCM" ), ), ), ( "insecure", FixedValue( True, title=_("Insecure"), totext=_("Disable SSL certificate verification"), help=_( "Ignore unverified HTTPS request warnings when contacting CUCM" ), ), ), ], ) # GUI config page for checks. We do a deep copy of the above function and just # change the title. A bit hackish since we're changing a private attribute. def _valuespec_special_agents_cucm_chk(): inv_spec = _valuespec_special_agents_cucm_inv() chk_spec = copy.deepcopy(inv_spec) chk_spec._title=_("CUCM checks") return chk_spec rulespec_registry.register( HostRulespec( factory_default=Rulespec.FACTORY_DEFAULT_UNUSED, name="special_agents:cucm_inv", group=RulespecGroupInventory, valuespec=_valuespec_special_agents_cucm_inv, ) ) rulespec_registry.register( HostRulespec( factory_default=Rulespec.FACTORY_DEFAULT_UNUSED, name="special_agents:cucm_chk", group=RulespecGroupCheckParametersHardware, valuespec=_valuespec_special_agents_cucm_chk, ) )