mirror of
https://github.com/TheNetworkGuy/netbox-zabbix-sync.git
synced 2025-07-16 04:02:56 -06:00
feat: support overridable template contexts using dictionaries
This commit is contained in:
parent
908e7eeda9
commit
4a4919053f
@ -156,9 +156,15 @@ class PhysicalDevice():
|
|||||||
e = (f"Host {self.name}: Key 'templates' not found in config "
|
e = (f"Host {self.name}: Key 'templates' not found in config "
|
||||||
"context 'zabbix' for template lookup")
|
"context 'zabbix' for template lookup")
|
||||||
raise TemplateError(e)
|
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):
|
if isinstance(self.config_context["zabbix"]["templates"], str):
|
||||||
return [self.config_context["zabbix"]["templates"]]
|
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"]
|
return self.config_context["zabbix"]["templates"]
|
||||||
|
|
||||||
def set_inventory(self, nbdevice):
|
def set_inventory(self, nbdevice):
|
||||||
|
Loading…
Reference in New Issue
Block a user