Skip to content

Commit

Permalink
Merge pull request ManageIQ#15783 from Ladas/make_networks_vms_relati…
Browse files Browse the repository at this point in the history
…on_distinct

Make networks vms relations distinct
  • Loading branch information
agrare authored Aug 10, 2017
2 parents d8e59f5 + 77a77d7 commit 51c45fa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/cloud_network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class CloudNetwork < ApplicationRecord
has_many :cloud_subnets, :dependent => :destroy
has_many :network_routers, -> { distinct }, :through => :cloud_subnets
has_many :public_networks, -> { distinct }, :through => :cloud_subnets
has_many :network_ports, :through => :cloud_subnets
has_many :network_ports, -> { distinct }, :through => :cloud_subnets
has_many :floating_ips, :dependent => :destroy
has_many :vms, :through => :network_ports, :source => :device, :source_type => 'VmOrTemplate'
has_many :vms, -> { distinct }, :through => :network_ports, :source => :device, :source_type => 'VmOrTemplate'

has_many :public_network_vms, -> { distinct }, :through => :public_network_routers, :source => :vms
has_many :public_network_routers, :foreign_key => :cloud_network_id, :class_name => NetworkRouter
Expand Down Expand Up @@ -42,7 +42,7 @@ class CloudNetwork < ApplicationRecord
end
end

virtual_total :total_vms, :vms, :uses => :vms
virtual_total :total_vms, :vms

def self.class_by_ems(ext_management_system, _external = false)
# TODO: A factory on ExtManagementSystem to return class for each provider
Expand Down

0 comments on commit 51c45fa

Please sign in to comment.