Skip to content

Commit

Permalink
Merge pull request #149 from Ladas/pass_collector_to_persister_to_mak…
Browse files Browse the repository at this point in the history
…e_targeted_refresh_work

Pass collector to persister to make targeted refresh work
  • Loading branch information
durandom authored Feb 27, 2017
2 parents c777f4d + 700dfb6 commit c5c422e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
7 changes: 4 additions & 3 deletions app/models/manageiq/providers/amazon/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ def cloud_manager_inventory(ems, target)
)
end

def inventory(manager, raw_target, collector_class, target_class, parsers_classes)
def inventory(manager, raw_target, collector_class, persister_class, parsers_classes)
collector = collector_class.new(manager, raw_target)
target = target_class.new(manager, raw_target)
# TODO(lsmola) figure out a way to pass collector info, probably via target
persister = persister_class.new(manager, raw_target, collector)

::ManageIQ::Providers::Amazon::Inventory.new(
target,
persister,
collector,
parsers_classes.map(&:new)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ManageIQ::Providers::Amazon::Inventory::Collector::TargetCollection < ManageIQ::Providers::Amazon::Inventory::Collector
def initialize(_ems, _options, _target)
def initialize(_manager, _target)
super
parse_targets!
infer_related_ems_refs!
Expand Down Expand Up @@ -188,7 +188,7 @@ def infer_related_ems_refs!
# ems_refs of every related object. Now this is not very nice fro ma design point of view, but we really want
# to see changes in VM's associated objects, so the VM view is always consistent and have fresh data. The partial
# reason for this is, that AWS doesn't send all the objects state change,
changed_vms = ems.vms.where(:ems_ref => instances_refs.to_a).includes(:key_pairs, :network_ports, :floating_ips,
changed_vms = manager.vms.where(:ems_ref => instances_refs.to_a).includes(:key_pairs, :network_ports, :floating_ips,
:orchestration_stack)
changed_vms.each do |vm|
stack = vm.orchestration_stack
Expand Down
15 changes: 15 additions & 0 deletions app/models/manageiq/providers/amazon/inventory/persister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ class ManageIQ::Providers::Amazon::Inventory::Persister < ManagerRefresh::Invent
require_nested :NetworkManager
require_nested :TargetCollection

# TODO(lsmola) figure out a way to pass collector info, probably via target, then remove the below
attr_reader :collector
# @param manager [ManageIQ::Providers::BaseManager] A manager object
# @param target [Object] A refresh Target object
# @param target [ManagerRefresh::Inventory::Collector] A Collector object
def initialize(manager, target, collector)
@manager = manager
@target = target
@collector = collector

@collections = {}

initialize_inventory_collections
end

protected

def cloud
Expand Down

0 comments on commit c5c422e

Please sign in to comment.