Fix multiple parents error moving vm to new folder #17525
Merged
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.
Linking inventory when doing a targeted refresh switches when to
disconnect relationships depending on what the target type is. This is
due to the fact that the full list of items for e.g. folders/clustes is
only known when running a full refresh, otherwise it has a sparse list.
Currently the folders_to_vms relat is only disconnected when refreshing
a full ems.
When moving a vm to a new folder the Move Into event queues a full
refresh, and the VM Relocate event queues a host targeted refresh.
The issue is when moving a vm to a new host and a new folder, the host
event queues a targeted refresh but the vm being moved to a new folder
is picked up in this targeted refresh also.
This leads to the do_disconnect value being false when processing the
folders_to_vms relationship leading to the multiple parents error.
To fix this we can process the folders_to_vms under the section where it
disconnects if the target type is a VmOrTemplate.
Steps for Testing
catcher running).
EmsRefresh.refresh(ExtManagementSystem.first)
vm = Vm.find_by(:name => "vm name"); EmsRefresh.refresh(vm)
vm.reload.parent_blue_folder