diff --git a/app/models/ems_cluster.rb b/app/models/ems_cluster.rb index cb6784f51ca3..d6c687d06311 100644 --- a/app/models/ems_cluster.rb +++ b/app/models/ems_cluster.rb @@ -34,6 +34,8 @@ class EmsCluster < ApplicationRecord virtual_has_many :storages, :uses => {:hosts => :storages} virtual_has_many :resource_pools, :uses => :all_relationships + virtual_has_many :lans, :uses => {:hosts => :lans} + has_many :failover_hosts, -> { failover }, :class_name => "Host" include SerializedEmsRefObjMixin @@ -230,6 +232,12 @@ def memory_reserve get_reserve(:memory_reserve) end + def lans + hosts = all_hosts + MiqPreloader.preload(hosts, :lans) + hosts.collect(&:lans).flatten.compact.uniq + end + def effective_resource(resource) resource = resource.to_s unless %w(cpu vcpu memory).include?(resource)