Skip to content

Commit

Permalink
target new refresh fails
Browse files Browse the repository at this point in the history
When running publish vm workflow flow I saw:

[NoMethodError]: undefined method `base_class' for NilClass:Class  Method:[block in method_missing]
relationship_mixin.rb:621:in `block in remove_children'

and it is triggered from `save_ems_inventory_no_disconnect`. It means that `link_invenotry` do not
respects disconnect flag which is fixed by this patch.
  • Loading branch information
pkliczewski committed Sep 27, 2017
1 parent b5c8550 commit d1ff546
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
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

0 comments on commit d1ff546

Please sign in to comment.