Repository navigation
vmware: take parent_folder_2 tags from the folder two levels up - #638
Open
tyderian1978 wants to merge 1 commit into
Open
tyderian1978 wants to merge 1 commit into
tyderian1978 wants to merge 1 commit into
Conversation
The 'parent_folder_2' tag source is documented as the folder an object is organized in 2 levels up, but collect_object_tags() looked up the first folder above the object a second time and used the tags of parent_folder_1. On its own 'parent_folder_2' gave the direct folder's tags, together with 'parent_folder_1' the same tags twice. parent_folder_2 is now the folder that parent_folder_1 is organized in. If parent_folder_1 is the top VM or host folder of a datacenter there is none.
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.
Disclaimer: AI generated, based off the work we're doing with Netbox.
What happens
The
parent_folder_2tag source is documented as "the indirect folder this object is organized in (2 levels up)".collect_object_tags()looks it up withget_parent_object_by_class(obj, vim.Folder), the same call it uses forparent_folder_1, so both return the first folder above the object:vm_tag_source = parent_folder_2gives the tags of the direct folder instead of the folder above itvm_tag_source = parent_folder_1, parent_folder_2gives the direct folder's tags twice and never the second folder'sThe same applies to
host_tag_sourceandcluster_tag_source.Fix
parent_folder_2is now the folder thatparent_folder_1is organized in. Whenparent_folder_1is the top VM or host folder of a datacenter, the next level up is the datacenter itself, so there is no second folder. Setups usingparent_folder_2will see their synced tags change to what the documentation describes.The new lookup reads the folder's parent directly. Once #634 is merged, I'll route it through #634's per-run parent cache.
Tests
tests/test_vmware_tag_sources.pyuses a faked tagging API and a folder treedatacenter / vm / Dept / Prodin which every folder carries one tag:parent_folder_1for a VM in Prod gives Prod's tag (unchanged)parent_folder_2gives Dept's tag, and both together give Prod's and Dept'sparent_folder_2adds nothingThe three
parent_folder_2cases fail ondevelopment. Full suite: 838 passed, 8 skipped.