Skip to content

Commit

Permalink
Merge pull request ManageIQ#15804 from cben/rename-hashes
Browse files Browse the repository at this point in the history
Rename `hashes` variables that now hold hashes/collections
  • Loading branch information
agrare authored Aug 15, 2017
2 parents aad4439 + 42f56b6 commit 947ff80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 8 additions & 8 deletions app/models/ems_refresh/refreshers/ems_refresher_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@ def refresh_targets_for_ems(ems, targets)
target, inventory = targets_with_inventory.shift

_log.info "#{log_header} Refreshing target #{target.class} [#{target.name}] id [#{target.id}]..."
hashes, _ = Benchmark.realtime_block(:parse_targeted_inventory) do
parsed, _ = Benchmark.realtime_block(:parse_targeted_inventory) do
parse_targeted_inventory(ems, target, inventory)
end
inventory = nil # clear to help GC

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

if hashes.kind_of?(Array)
if parsed.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) }
Benchmark.realtime_block(:manager_refresh_post_processing) { manager_refresh_post_processing(ems, target, parsed) }
_log.info "#{log_header} ManagerRefresh Post Processing #{target.class} [#{target.name}] id [#{target.id}]...Complete"
end
end
Expand Down Expand Up @@ -155,13 +155,13 @@ def parse_targeted_inventory(ems, target, collector)
_log.debug "#{log_header} Parsing inventory...Complete"
inventory_collections
else
hashes, = Benchmark.realtime_block(:parse_legacy_inventory) { parse_legacy_inventory(ems) }
hashes
parsed, _ = Benchmark.realtime_block(:parse_legacy_inventory) { parse_legacy_inventory(ems) }
parsed
end
end

def save_inventory(ems, target, hashes)
EmsRefresh.save_ems_inventory(ems, hashes, target)
def save_inventory(ems, target, parsed)
EmsRefresh.save_ems_inventory(ems, parsed, target)
end

def post_refresh_ems_cleanup(_ems, _targets)
Expand Down
8 changes: 5 additions & 3 deletions app/models/ems_refresh/save_inventory.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module EmsRefresh::SaveInventory
def save_ems_inventory(ems, hashes, target = nil, disconnect = true)
if hashes.kind_of?(Array)
ManagerRefresh::SaveInventory.save_inventory(ems, hashes)
# Parsed inventory can come as hash of hashes or array of InventoryCollection's.
def save_ems_inventory(ems, hashes_or_collections, target = nil, disconnect = true)
if hashes_or_collections.kind_of?(Array)
ManagerRefresh::SaveInventory.save_inventory(ems, hashes_or_collections) # InventoryCollections.
return
end
hashes = hashes_or_collections

case ems
when EmsCloud then save_ems_cloud_inventory(ems, hashes, target, disconnect)
Expand Down

0 comments on commit 947ff80

Please sign in to comment.