From 4a4919053f9037d080863d01396bb30ffda618e4 Mon Sep 17 00:00:00 2001 From: Ryazanov Alexander Mihailovich Date: Thu, 29 May 2025 16:14:39 +0300 Subject: [PATCH] feat: support overridable template contexts using dictionaries --- modules/device.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/device.py b/modules/device.py index 2ed37e8..21fcd73 100644 --- a/modules/device.py +++ b/modules/device.py @@ -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):