Skip to content

Commit

Permalink
Allow to run post processing job for ManagerRefresh (Graph Refresh)
Browse files Browse the repository at this point in the history
Allow to run post processing job for ManagerRefresh (Graph Refresh).
This post processing can leverage existing data in the
InventoryCollection and especially each collection's created_records,
updated_records and deleted_records, to queue up specific post
processing jobs.
  • Loading branch information
Ladas committed Jul 28, 2017
1 parent fe1f825 commit 04f82ac
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/models/ems_refresh/refreshers/ems_refresher_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ def preprocess_targets
end

def refresh_targets_for_ems(ems, targets)
# handle a 3-part inventory refresh process
# handle a 4-part inventory refresh process
# 1. collect inventory
# 2. parse inventory
# 3. save inventory
# 4. post process inventory (only when using InventoryCollections)
log_header = format_ems_for_logging(ems)

targets_with_inventory, _ = Benchmark.realtime_block(:collect_inventory_for_targets) do
Expand All @@ -90,9 +91,20 @@ def refresh_targets_for_ems(ems, targets)

Benchmark.realtime_block(:save_inventory) { save_inventory(ems, target, hashes) }
_log.info "#{log_header} Refreshing target #{target.class} [#{target.name}] id [#{target.id}]...Complete"

if hashes.kind_of?(Array)
_log.info "#{log_header} ManagerRefresh Post Processing #{target.class} [#{target.name}] id [#{target.id}]..."
# We have array of InventoryCollection, we want to use that data for post refresh
Benchmark.realtime_block(:manager_refresh_post_processing) { manager_refresh_post_processing(ems, target, hashes) }
_log.info "#{log_header} ManagerRefresh Post Processing #{target.class} [#{target.name}] id [#{target.id}]...Complete"
end
end
end

def manager_refresh_post_processing(_ems, _target, _inventory_collections)
# Implement post refresh actions in a specific refresher
end

def collect_inventory_for_targets(ems, targets)
# TODO: implement this method in all refreshers and remove from here
# legacy refreshers collect inventory during the parse phase so the
Expand Down

0 comments on commit 04f82ac

Please sign in to comment.