Skip to content

Commit

Permalink
Fix fetching templates via old API code
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed Aug 14, 2024
1 parent 2dfd5bb commit f6874f4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions zabbix_auto_config/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1448,9 +1448,10 @@ def do_update(self) -> None:
managed_template_names = set(
itertools.chain.from_iterable(self.property_template_map.values())
)
zabbix_templates = {}
for zabbix_template in self.api.template.get(output=["host", "templateid"]):
zabbix_templates[zabbix_template["host"]] = zabbix_template["templateid"]
zabbix_templates: Dict[str, Template] = {}
for zabbix_template in self.api.get_templates():
zabbix_templates[zabbix_template.host] = zabbix_template

managed_template_names = managed_template_names.intersection(
set(zabbix_templates.keys())
) # If the template isn't in zabbix we can't manage it
Expand Down Expand Up @@ -1489,7 +1490,7 @@ def do_update(self) -> None:
db_host = db_hosts[zabbix_hostname]

# Determine managed templates
synced_template_names = set()
synced_template_names: Set[str] = set()
for prop in db_host.properties:
if template_names := self.property_template_map.get(prop):
synced_template_names.update(template_names)
Expand Down

0 comments on commit f6874f4

Please sign in to comment.