Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Load Lans efficiently in ProvisionWorkflow #73

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ def filter_hosts_by_vlan_name(all_hosts)
end

def load_hosts_vlans(hosts, vlans)
hosts.each do |h|
h.lans.each do |l|
next if l.switch.shared?

lan_name = l.parent.nil? ? l.name : "#{l.parent.name} / #{l.name}"
vlans[l.uid_ems] = lan_name
end
lans_for_hosts = Lan.distinct.select(:id, :switch_id, :uid_ems, :name)
.includes(:parent)
.joins(:switch => :host_switches)
.where(:host_switches => {:host_id => hosts.map(&:id)})
.where(:switches => {:shared => [nil, false]})

lans_for_hosts.each do |l|
lan_name = l.parent.nil? ? l.name : "#{l.parent.name} / #{l.name}"
vlans[l.uid_ems] = lan_name
end
end

Expand Down