Skip to content

Commit

Permalink
[miq_provision_virt_workflow.rb] Skip debug loop
Browse files Browse the repository at this point in the history
If we aren't in DEBUG mode for `_log` (evm.log), render the strings and
loop through the list to "print debug statements.  Also fixed some
rubocop complexity issues by moving this logic into it's own method.
  • Loading branch information
NickLaMuro committed Jan 16, 2019
1 parent 2547cca commit 7a04c48
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/models/miq_provision_virt_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,7 @@ def allowed_templates(options = {})
@allowed_templates_filter = filter_id
@allowed_templates_tag_filters = @values[:vm_tags]
rails_logger('allowed_templates', 1)
if allowed_templates_list.blank?
_log.warn("Allowed Templates is returning an empty list")
else
_log.warn("Allowed Templates is returning <#{allowed_templates_list.length}> template(s)")
allowed_templates_list.each do |vm|
_log.debug("Allowed Template <#{vm.id}:#{vm.name}> GUID: <#{vm.guid}> UID_EMS: <#{vm.uid_ems}>")
end
end
log_allowed_template_list(allowed_templates_list)

MiqPreloader.preload(allowed_templates_list, [:snapshots, :operating_system, :ext_management_system, {:hardware => :disks}])
@allowed_templates_cache = allowed_templates_list.collect do |template|
Expand Down Expand Up @@ -1092,4 +1085,17 @@ def selected_host(src)
raise _("Unable to find Host with Id: [%{id}]") % {:id => src[:host_id]} if src[:host].nil?
[load_ar_obj(src[:host])]
end

def log_allowed_template_list(template_list)
if template_list.blank?
_log.warn("Allowed Templates is returning an empty list")
else
_log.warn("Allowed Templates is returning <#{template_list.length}> template(s)")
if _log.level == Logger::DEBUG # skip .each if not in DEBUG
template_list.each do |vm|
_log.debug("Allowed Template <#{vm.id}:#{vm.name}> GUID: <#{vm.guid}> UID_EMS: <#{vm.uid_ems}>")
end
end
end
end
end

0 comments on commit 7a04c48

Please sign in to comment.