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

Fix save_inventory error if lan can't be found #18433

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/models/ems_refresh/save_inventory_infra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ def save_miq_scsi_luns_inventory(miq_scsi_target, hashes)
end

def save_switches_inventory(host, hashes)
ems = host.ext_management_system
log_header = "EMS: [#{ems.name}], id: [#{ems.id}]"

already_saved, not_yet_saved = hashes.partition { |h| h[:id] }
save_inventory_multi(host.switches, not_yet_saved, [], [:uid_ems], :lans)
host_switches_hash = already_saved.collect { |switch| {:host_id => host.id, :switch_id => switch[:id]} }
Expand All @@ -321,6 +324,11 @@ def save_switches_inventory(host, hashes)
next if sh[:lans].nil?
sh[:lans].each do |lh|
lan = switch.lans.detect { |l| l.uid_ems == lh[:uid_ems] }
if lan.nil?
_log.warn("#{log_header} Failed to find lan [#{lh[:uid_ems]}] for switch ID [#{switch.id}]")
next
end

lh[:id] = lan.id
end
end
Expand Down