Skip to content

Commit

Permalink
Apply distinct on LAN/switch selection
Browse files Browse the repository at this point in the history
Several hosts might be connected to the same switch, sharing the same
LAN. Therefore it is required to apply 'DISTINCT' on the result of the
join of these tables.
  • Loading branch information
masayag committed Sep 4, 2017
1 parent 28a0164 commit 7e6ab4f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app/models/manageiq/providers/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ class InfraManager < BaseManager

include AvailabilityMixin

has_many :host_hardwares, :through => :hosts, :source => :hardware
has_many :host_operating_systems, :through => :hosts, :source => :operating_system
has_many :host_storages, :through => :hosts
has_many :host_switches, :through => :hosts
has_many :host_networks, :through => :hosts, :source => :networks
has_many :snapshots, :through => :vms_and_templates
has_many :operating_systems, :through => :vms_and_templates
has_many :switches, :through => :hosts
has_many :lans, :through => :hosts
has_many :networks, :through => :hardwares
has_many :guest_devices, :through => :hardwares
has_many :host_hardwares, :through => :hosts, :source => :hardware
has_many :host_operating_systems, :through => :hosts, :source => :operating_system
has_many :host_storages, :through => :hosts
has_many :host_switches, :through => :hosts
has_many :host_networks, :through => :hosts, :source => :networks
has_many :snapshots, :through => :vms_and_templates
has_many :operating_systems, :through => :vms_and_templates
has_many :switches, -> { distinct }, :through => :hosts
has_many :lans, -> { distinct }, :through => :hosts
has_many :networks, :through => :hardwares
has_many :guest_devices, :through => :hardwares

class << model_name
define_method(:route_key) { "ems_infras" }
Expand Down

0 comments on commit 7e6ab4f

Please sign in to comment.