Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target new refresh fails #16043

Merged
merged 1 commit into from Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions 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}")
Expand All @@ -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|
Expand Down Expand Up @@ -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|
Expand Down Expand Up @@ -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

#
Expand Down
2 changes: 1 addition & 1 deletion app/models/ems_refresh/save_inventory_infra.rb
Expand Up @@ -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
Expand Down