diff --git a/app/models/ems_refresh/link_inventory.rb b/app/models/ems_refresh/link_inventory.rb index b460ce62042d..e702d1232e9b 100644 --- a/app/models/ems_refresh/link_inventory.rb +++ b/app/models/ems_refresh/link_inventory.rb @@ -123,7 +123,7 @@ def link_ems_inventory(ems, target, prev_relats, new_relats, disconnect = true) 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