fix: do not adopt a same-named cluster another source keeps in a different site - #557
Open
semx wants to merge 2 commits into
Open
fix: do not adopt a same-named cluster another source keeps in a different site#557semx wants to merge 2 commits into
semx wants to merge 2 commits into
Conversation
This was referenced Sep 9, 2026
…tching-other-source
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.
Fixes #501
With two vCenters that use the same datacenter and cluster names,
add_cluster()falls back to a name-only match and adopts the cluster the other source created. The second source then tries to move that cluster to its own site, which NetBox rejects because the first vCenter's hosts live in the other site (4 devices are assigned as hosts for this cluster but are not in site SR1), and its hosts end up attached to the wrong cluster. Settingset_source_name_as_cluster_groupdoes not help, the name-only fallback still wins.A same-named candidate is now skipped when this source assigns a site, the candidate is scoped to a different site, and it is maintained by another configured source (the source that touched it in this run, or its source tag for objects read from NetBox). Everything else is unchanged: a single source still re-scopes its own cluster, adopts a cluster from a renamed source, and adopts a site-less cluster (covered by tests that pass before and after).
Reproduced end to end with two vcsim instances carrying identical datacenter/cluster names: before, one cluster with
scope_idflipping between the sites and the second vCenter's hosts on the first cluster; after, two clusters with their own hosts. Tests:tests/test_vmware_cluster_matching.py, 3 cases fail ondevelopmentand pass here, 3 guard cases pass on both. Full suite: 88 passed.Rebased on current
development. #566 landed in the meantime and also touchesadd_cluster(), putting the site object intoscope_idinstead of a dict; the two sit next to each other without conflict andget_site_name()still resolves the candidate's site in the object form this check relies on. Suite 149 with both in.