Skip to content

Commit

Permalink
Merge pull request #17019 from jntullo/ems_cluster_lans
Browse files Browse the repository at this point in the history
Add lans as a virtual relationship to ems_cluster
(cherry picked from commit 4e212e4)
  • Loading branch information
agrare authored and simaishi committed May 29, 2018
1 parent b272ec1 commit 96fdbc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/ems_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions app/models/mixins/aggregation_mixin/methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,11 @@ def aggregate_hardware(from, field, targets = nil)

hdws.inject(0) { |t, hdw| t + hdw.send(field).to_i }
end

def lans
hosts = all_hosts
MiqPreloader.preload(hosts, :lans)
hosts.flat_map(&:lans).compact.uniq
end
end
end

0 comments on commit 96fdbc3

Please sign in to comment.