Skip to content

Commit

Permalink
Fix missing do_disconnect check in link_inventory
Browse files Browse the repository at this point in the history
Fixes an issue found by #16718
where relationships are deleted even though disconnect is false.
  • Loading branch information
agrare committed Jan 3, 2018
1 parent 14d1aa3 commit 6e27afc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/models/ems_refresh/link_inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,16 @@ def link_ems_inventory(ems, target, prev_relats, new_relats, disconnect = true)
end

# Do the VMs to * relationships
# We do disconnects for all refresh types since we have enough
# information in the filtered data for all refresh types
# We do disconnects for EMS, Host, and Vm target types since
# we have enough information in the filtered data

do_disconnect ||= target.kind_of?(VmOrTemplate) if disconnect

# Do the ResourcePools to VMs relationships
update_relats(:resource_pools_to_vms, prev_relats, new_relats) do |r|
rp = instance_with_id(ResourcePool, r)
break if rp.nil?
[proc { |v| rp.remove_vm(instance_with_id(VmOrTemplate, v)) }, # Disconnect proc
[do_disconnect ? proc { |v| rp.remove_vm(instance_with_id(VmOrTemplate, v)) } : nil, # Disconnect proc
proc { |v| rp.add_vm(instance_with_id(VmOrTemplate, v)) }, # Connect proc
proc { |vs| rp.add_vm(instances_with_ids(VmOrTemplate, vs)) }] # Bulk connect proc
end
Expand Down

0 comments on commit 6e27afc

Please sign in to comment.