Fix: Add SiteGroup parent traversal to inheritance chain#112
Closed
berlikm wants to merge 5 commits into
Closed
Conversation
berlikm
force-pushed
the
fix/sitegroup-parent-inheritance
branch
2 times, most recently
from
July 14, 2026 13:23
9d32877 to
d8c69ad
Compare
Adds Site, SiteGroup, and Region as valid assignment targets for all ZabbixServerAssignment, ZabbixHostgroupAssignment, ZabbixTemplateAssignment, ZabbixTagAssignment, ZabbixMacroAssignment, and ZabbixHostInventory objects. This allows assignments made at the Site/SiteGroup/Region level to be inherited by all devices and VMs at that site or below, via the existing inheritance_chain mechanism. Changes: - Constants: Site/SiteGroup/Region added to ASSIGNMENT_MODELS, ASSIGNMENT_TYPE_TO_FIELD, PATH_LABELS - Forms: All 7 assignment forms get Site/SiteGroup/Region DynamicModelChoiceField + FieldSet - Settings: inheritance_chain extended with Site/SiteGroup/Region resolution paths - Jobs: SyncHostJob._prepare_assignment() creates detached copies for inherited assignments - HostSync: _get_sync_target() resolves actual Device/VM for Jinja2 rendering - HostSync: get_tag_attributes() deduplicates tags by (tag, value) to prevent Zabbix 7 rejecting duplicate pairs inherited from multiple sources - HostInterfaceSync: get_create_params() falls back to the device's primary IP when the interface has no IP assigned (e.g. when inherited from SiteGroup) - HostInterfaceSync: errors are caught per-interface so one failing interface does not prevent the remaining interfaces and templates from being synced - Inheritance: ConfigGroup interface expansion removed; interfaces are now resolved naturally via the inheritance chain with primary IP fallback - SyncBase: _is_inherited_copy guard prevents save()/update_sync_info() on inherited copies - Views: ZabbixSiteTabView, ZabbixSiteGroupTabView, ZabbixRegionTabView added - Tests: 9 new tests for inheritance resolution Tested: all 1076 existing tests pass. Verified end-to-end on dev NetBox.
- Filter inherited/direct ZabbixServerAssignment and ZabbixHostInterface by zabbixserver - Resolve ConfigGroup interface IP from primary_ip4/primary_ip6 - Add seen-set cycle guard to resolve_path
- Fixes silent dropping of Site/SiteGroup assignments
berlikm
force-pushed
the
fix/sitegroup-parent-inheritance
branch
from
July 14, 2026 14:34
d8c69ad to
fac2951
Compare
Fixes inherited Site/SiteGroup/Region assignments reading custom fields from the intermediate object instead of the actual Device/VM.
The inheritance chain included ('region', 'parent') for traversing the
Region hierarchy, but had no equivalent for SiteGroup. A ZabbixServerAssignment
on a parent SiteGroup (e.g. 'CH') was invisible to devices at sites in
child groups (e.g. 'CH-STA-L26').
Adds ('group', 'parent') and ('site', 'group', 'parent') to the chain,
mirroring the existing ('region', 'parent') pattern. Updates path_labels
with matching labels.
Tested: all 1092 existing tests pass. Verified on dev NetBox — device
at site CH-STA-L26 now inherits ZabbixServerAssignment from SiteGroup CH.
berlikm
force-pushed
the
fix/sitegroup-parent-inheritance
branch
from
July 14, 2026 15:01
fac2951 to
30e50f0
Compare
Author
|
This PR is part of the zero-touch provisioning feature set described in #121. Please see that issue for the full architecture and motivation. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The inheritance chain included
('region', 'parent')for traversing the Region hierarchy, but had no equivalent for SiteGroup. AZabbixServerAssignmenton a parent SiteGroup (e.g. 'CH') was invisible to devices at sites in child groups (e.g. 'CH-STA-L26').Fix
Add two new entries to the inheritance chain:
('group', 'parent')— resolves SiteGroup.parent from any object that has a direct SiteGroup reference('site', 'group', 'parent')— resolves device.site.group.parent, traversing the full SiteGroup hierarchyAlso adds matching entries in
PATH_LABELSanddocs/configuration.md.Files changed
nbxsync/__init__.py— Added['group', 'parent']and['site', 'group', 'parent']to default settingsnbxsync/settings.py— Added('site', 'group', 'parent')to defaultsnbxsync/constants/path_labels.py— Added path labelsdocs/configuration.md— Updated inheritance_chain exampleTesting
All 1076 existing tests pass. Verified on dev NetBox — a device at site CH-STA-L26 inherits ZabbixServerAssignment from parent SiteGroup CH.
Dependencies
This PR is built on top of PR #115 (Site/Region inheritance). Once #115 is merged, this PR can be rebased to show only its own 1 commit.