feat: support overridable template contexts using dictionaries

This commit is contained in:
Ryazanov Alexander Mihailovich 2025-05-29 16:14:39 +03:00 committed by GitHub
parent 908e7eeda9
commit 4a4919053f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -156,9 +156,15 @@ class PhysicalDevice():
e = (f"Host {self.name}: Key 'templates' not found in config "
"context 'zabbix' for template lookup")
raise TemplateError(e)
# Check if format is list or string.
# Check if format is list, dictionary or string.
if isinstance(self.config_context["zabbix"]["templates"], str):
return [self.config_context["zabbix"]["templates"]]
elif isinstance(self.config_context["zabbix"]["templates"], dict):
return [
template
for template, enabled in self.config_context["zabbix"]["templates"].items()
if enabled
]
return self.config_context["zabbix"]["templates"]
def set_inventory(self, nbdevice):