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

Make networks vms relations distinct #15783

Merged
merged 1 commit into from
Aug 10, 2017
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
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