diff --git a/app/models/ems_refresh/link_inventory.rb b/app/models/ems_refresh/link_inventory.rb index 0049ca92012..c91eea16bab 100644 --- a/app/models/ems_refresh/link_inventory.rb +++ b/app/models/ems_refresh/link_inventory.rb @@ -1,6 +1,6 @@ module EmsRefresh::LinkInventory # Link EMS inventory through the relationships table - def link_ems_inventory(ems, target, prev_relats, new_relats) + def link_ems_inventory(ems, target, prev_relats, new_relats, disconnect = true) log_header = "EMS: [#{ems.name}], id: [#{ems.id}]" _log.info("#{log_header} Linking EMS Inventory...") _log.debug("#{log_header} prev_relats: #{prev_relats.inspect}") @@ -23,7 +23,7 @@ def link_ems_inventory(ems, target, prev_relats, new_relats) # Do the Folders to *, and Clusters to * relationships # For these, we only disconnect when doing an EMS refresh since we don't have # enough information in the filtered data for other refresh types - do_disconnect = target.kind_of?(ExtManagementSystem) + do_disconnect = target.kind_of?(ExtManagementSystem) if disconnect # Do the Folders to Folders relationships update_relats(:folders_to_folders, prev_relats, new_relats) do |f| @@ -81,7 +81,7 @@ def link_ems_inventory(ems, target, prev_relats, new_relats) # Do the Hosts to * relationships, ResourcePool to * relationships # For these, we only disconnect when doing an EMS or Host refresh since we don't # have enough information in the filtered data for other refresh types - do_disconnect ||= target.kind_of?(Host) + do_disconnect ||= target.kind_of?(Host) if disconnect # Do the Hosts to ResourcePools relationships update_relats(:hosts_to_resource_pools, prev_relats, new_relats) do |h| @@ -134,8 +134,7 @@ def link_habtm(object, hashes, accessor, model, do_disconnect = true) update_relats_by_ids(prev_ids, new_ids, do_disconnect ? proc { |s| object.send(accessor).delete(instance_with_id(model, s)) } : nil, # Disconnect proc proc { |s| object.send(accessor) << instance_with_id(model, s) }, # Connect proc - proc { |ss| object.send(accessor) << instances_with_ids(model, ss) } # Bulk connect proc - ) + proc { |ss| object.send(accessor) << instances_with_ids(model, ss) }) # Bulk connect proc end # diff --git a/app/models/ems_refresh/save_inventory_infra.rb b/app/models/ems_refresh/save_inventory_infra.rb index 843b5987bcd..448088cfd0f 100644 --- a/app/models/ems_refresh/save_inventory_infra.rb +++ b/app/models/ems_refresh/save_inventory_infra.rb @@ -77,7 +77,7 @@ def save_ems_infra_inventory(ems, hashes, target = nil, disconnect = true) _log.info("#{log_header} Saving EMS Inventory...Complete") new_relats = hashes_relats(hashes) - link_ems_inventory(ems, target, prev_relats, new_relats) + link_ems_inventory(ems, target, prev_relats, new_relats, disconnect) remove_obsolete_switches ems