Skip to content

Commit

Permalink
Add methods to access graph refresh settings
Browse files Browse the repository at this point in the history
Add some methods to the base manager refresher to access graph refresh
settings instead of the same logic sprinkled around.
  • Loading branch information
agrare committed Aug 28, 2018
1 parent 52f4799 commit f5bc9a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def collect_inventory_for_targets(ems, targets)

_log.info("Filtering inventory for #{target.class} [#{target_name}] id: [#{target.id}]...")

if refresher_options.try(:[], :inventory_object_refresh)
if inventory_object_refresh?
inventory = builder_class_for(ems.class).build_inventory(ems, target)
end

Expand All @@ -62,7 +62,7 @@ def parse_targeted_inventory(ems, _target, inventory)
log_header = format_ems_for_logging(ems)
_log.debug("#{log_header} Parsing inventory...")
hashes_or_persister, = Benchmark.realtime_block(:parse_inventory) do
if refresher_options.try(:[], :inventory_object_refresh)
if inventory_object_refresh?
inventory.parse
else
parsed, _ = Benchmark.realtime_block(:parse_legacy_inventory) { parse_legacy(ems) }
Expand All @@ -89,7 +89,7 @@ def preprocess_targets
all_targets, sub_ems_targets = targets.partition { |x| x.kind_of?(ExtManagementSystem) }

unless sub_ems_targets.blank?
if refresher_options.try(:[], :allow_targeted_refresh)
if allow_targeted_refresh?
# We can disable targeted refresh with a setting, then we will just do full ems refresh on any event
ems_event_collection = ManagerRefresh::TargetCollection.new(:targets => sub_ems_targets,
:manager_id => ems_id)
Expand Down
10 changes: 9 additions & 1 deletion app/models/manageiq/providers/base_manager/refresher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def collect_inventory_for_targets(ems, targets)
# override this method and return an array of:
# [[target1, inventory_for_target1], [target2, inventory_for_target2]]

return [[ems, nil]] unless refresher_options.inventory_object_refresh
return [[ems, nil]] unless inventory_object_refresh?

provider_module = ManageIQ::Providers::Inflector.provider_module(ems.class).name

Expand Down Expand Up @@ -252,6 +252,14 @@ def refresher_type
def format_ems_for_logging(ems)
"EMS: [#{ems.name}], id: [#{ems.id}]"
end

def inventory_object_refresh?
refresher_options.try(:[], :inventory_object_refresh)
end

def allow_targeted_refresh?
refresher_options.try(:[], :allow_targeted_refresh)
end
end
end
end

0 comments on commit f5bc9a9

Please sign in to comment.