diff --git a/app/models/cloud_network.rb b/app/models/cloud_network.rb index 49f4385d81fa..3aa93b079e25 100644 --- a/app/models/cloud_network.rb +++ b/app/models/cloud_network.rb @@ -16,6 +16,10 @@ class CloudNetwork < ApplicationRecord has_many :floating_ips, :dependent => :destroy has_many :vms, :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 + has_many :private_networks, -> { distinct }, :through => :public_network_routers, :source => :cloud_networks + # TODO(lsmola) figure out what this means, like security groups used by VMs in the network? It's not being # refreshed, so we can probably delete this association has_many :security_groups diff --git a/app/models/mixins/has_network_manager_mixin.rb b/app/models/mixins/has_network_manager_mixin.rb index c298db532f32..8e74cd734408 100644 --- a/app/models/mixins/has_network_manager_mixin.rb +++ b/app/models/mixins/has_network_manager_mixin.rb @@ -16,7 +16,6 @@ module HasNetworkManagerMixin :network_routers, :public_networks, :private_networks, - :all_private_networks, :all_cloud_networks, :to => :network_manager, :allow_nil => true