Add related object context to Zabbix tag and hostgroup templates#102
Add related object context to Zabbix tag and hostgroup templates#102taofineberg wants to merge 3 commits into
Conversation
- Updated the documentation ### New features - Updated the Zabbix Template Assignment and Zabbix Tag Assignment forms so no duplicate templates/tags can't be assigned ([OpensourceICTSolutions#78]) - Zabbix Macro's now support Jinja2 templated values ([OpensourceICTSolutions#83]) ### Bug fixes - Fixed issue with internationalization of field set names on forms ([OpensourceICTSolutions#39]) - Fixed typo in last_sync_message ([OpensourceICTSolutions#77]) - Fixed issue with API Schema not being able to generated ([OpensourceICTSolutions#79]) - Manual device sync fails for templated Zabbix hostgroups when the rendered local hostgroup does not already exist ([OpensourceICTSolutions#81]) - Ensure that the worker doesn't crash on certain race conditions with regards to the hostinterfacesync job ([OpensourceICTSolutions#86]) - Fix issue with DeleteHost so it now actually removed the device/object from Zabbix when its deleted from NetBox ([OpensourceICTSolutions#88])
|
Hey @taofineberg, Thanks for taking the time to work on this: exposing related object context directly in the Jinja2 templates is a great quality-of-life improvement. Really appreciate the initiative. I do have a few things that need to be addressed before we can merge this: Bug: manufacturer lookup crashes on VMs and Virtual Device Contexts Unrelated commits in the PR
Documentation The feature itself is solid and something users have been asking for. Once these items are addressed we should be good to go. Happy to help if you have questions on any of these points. Thanks again! |
Add related object context to Zabbix tag and hostgroup templates
Summary
Add related NetBox object context to templated Zabbix tags and hostgroups.
Previously, templates only had access to the assigned object through
object, plus the tag or hostgroup fields. This change exposes common related objects directly in the Jinja2 context when available.What Changed
This PR adds the following template variables for Zabbix tag and hostgroup templates:
devicesitetenantroledevice_typemanufacturerThis allows templates such as:
{{ site.name }}{{ device.name }}{{ device_type.model }}{{ manufacturer.name }}Why
This makes Zabbix tag and hostgroup templates easier to write and more flexible.
For example, users can now build dynamic tag or hostgroup values from related NetBox data without having to access everything indirectly through
object.Implementation
ZabbixTagAssignment.get_context()to include related object context.ZabbixHostgroupAssignment.get_context()to include related object context.Testing
git diff --checkpassed.ruffwas not run because it is not installed in this container.manage.pyin/opt/nbxsync.