Skip to content

Commit

Permalink
Merge pull request #15678 from Ladas/manager_refresh_post_processing_…
Browse files Browse the repository at this point in the history
…block

Allow to run post processing job for ManagerRefresh (Graph Refresh)
  • Loading branch information
agrare authored Aug 1, 2017
2 parents a139ce6 + 04f82ac commit 7d10409
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 7d10409

Please sign in to comment.