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

Add lans as a virtual relationship to ems_cluster #17019

Merged
merged 1 commit into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
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
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