Skip to content

Commit

Permalink
Merge pull request ManageIQ#17070 from Ladas/core_changes_for_azure_t…
Browse files Browse the repository at this point in the history
…argeted_refresh

Core changes for azure targeted refresh
  • Loading branch information
agrare authored Mar 1, 2018
2 parents ea5ea7e + 55c7163 commit 08aaead
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
1 change: 1 addition & 0 deletions app/models/load_balancer_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class LoadBalancerPool < ApplicationRecord

has_many :load_balancer_listener_pools, :dependent => :destroy
has_many :load_balancer_listeners, :through => :load_balancer_listener_pools
has_many :load_balancers, :through => :load_balancer_listeners
has_many :load_balancer_pool_member_pools, :dependent => :destroy
has_many :load_balancer_pool_members, :through => :load_balancer_pool_member_pools

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def cloud_subnet_network_ports(extra_attributes = {})
:parent_inventory_collections => [:vms, :network_ports, :load_balancers],
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.cloud_subnet_network_ports.references(:network_ports).where(
:network_ports => {:ems_ref => manager_uuids}
Expand Down Expand Up @@ -114,9 +114,12 @@ def load_balancer_pools(extra_attributes = {})
}
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_pools.where(:ems_ref => manager_uuids)
inventory_collection.parent.load_balancer_pools
.joins(:load_balancers)
.where(:load_balancers => {:ems_ref => manager_uuids})
.distinct
end

attributes.merge!(extra_attributes)
Expand All @@ -132,12 +135,17 @@ def load_balancer_pool_members(extra_attributes = {})
}
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_pool_members
.joins(:load_balancer_pool_member_pools => :load_balancer_pool)
.where(:load_balancer_pool_member_pools => {'load_balancer_pools' => {:ems_ref => manager_uuids}})
.distinct
.joins(:load_balancer_pool_member_pools => [:load_balancer_pool => :load_balancers])
.where(:load_balancer_pool_member_pools => {
'load_balancer_pools' => {
'load_balancers' => {
:ems_ref => manager_uuids
}
}
}).distinct
end

attributes.merge!(extra_attributes)
Expand All @@ -151,11 +159,11 @@ def load_balancer_pool_member_pools(extra_attributes = {})
:parent_inventory_collections => [:load_balancers]
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_pool_member_pools
.references(:load_balancer_pools)
.where(:load_balancer_pools => {:ems_ref => manager_uuids})
.joins(:load_balancer_pool => :load_balancers)
.where(:load_balancer_pools => {'load_balancers' => {:ems_ref => manager_uuids}})
.distinct
end

Expand All @@ -173,11 +181,12 @@ def load_balancer_listeners(extra_attributes = {})
}
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_listeners.joins(:load_balancer).where(
:load_balancers => {:ems_ref => manager_uuids}
)
inventory_collection.parent.load_balancer_listeners
.joins(:load_balancer)
.where(:load_balancers => {:ems_ref => manager_uuids})
.distinct
end

attributes.merge!(extra_attributes)
Expand All @@ -191,11 +200,12 @@ def load_balancer_listener_pools(extra_attributes = {})
:parent_inventory_collections => [:load_balancers]
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_listener_pools.joins(:load_balancer_pool).where(
:load_balancer_pools => {:ems_ref => manager_uuids}
)
inventory_collection.parent.load_balancer_listener_pools
.joins(:load_balancer_pool => :load_balancers)
.where(:load_balancer_pools => {'load_balancers' => {:ems_ref => manager_uuids}})
.distinct
end

attributes.merge!(extra_attributes)
Expand All @@ -211,9 +221,12 @@ def load_balancer_health_checks(extra_attributes = {})
}
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_health_checks.where(:ems_ref => manager_uuids)
inventory_collection.parent.load_balancer_health_checks
.joins(:load_balancer)
.where(:load_balancers => {:ems_ref => manager_uuids})
.distinct
end

attributes.merge!(extra_attributes)
Expand All @@ -227,11 +240,12 @@ def load_balancer_health_check_members(extra_attributes = {})
:parent_inventory_collections => [:load_balancers],
}

extra_attributes[:targeted_arel] = lambda do |inventory_collection|
attributes[:targeted_arel] = lambda do |inventory_collection|
manager_uuids = inventory_collection.parent_inventory_collections.flat_map { |c| c.manager_uuids.to_a }
inventory_collection.parent.load_balancer_health_check_members.references(:load_balancer_health_checks).where(
:load_balancer_health_checks => {:ems_ref => manager_uuids}
)
inventory_collection.parent.load_balancer_health_check_members
.joins(:load_balancer_health_check => :load_balancer)
.where(:load_balancer_health_checks => {'load_balancers' => {:ems_ref => manager_uuids}})
.distinct
end

attributes.merge!(extra_attributes)
Expand Down

0 comments on commit 08aaead

Please sign in to comment.