class ForemanInventoryUpload::Async::GenerateAllReportsJob

Public Instance Methods

logger() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 36
def logger
  action_logger
end
plan() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 6
def plan
  unless Setting[:allow_auto_inventory_upload]
    logger.debug(
      'The scheduled process is disabled due to the "allow_auto_inventory_upload"
      setting being set to false.'
    )
    return
  end

  organizations = Organization.unscoped.all

  organizations.map do |organization|
    total_hosts = ForemanInventoryUpload::Generators::Queries.for_org(organization.id, use_batches: false).count

    if total_hosts <= ForemanInventoryUpload.max_org_size
      plan_generate_report(ForemanInventoryUpload.generated_reports_folder, organization)
    else
      logger.info("Skipping automatic uploads for organization #{organization.name}, too many hosts (#{total_hosts}/#{ForemanInventoryUpload.max_org_size})")
    end
  end.compact
end
plan_generate_report(folder, organization) click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 32
def plan_generate_report(folder, organization)
  plan_action(ForemanInventoryUpload::Async::GenerateReportJob, folder, organization.id)
end
rescue_strategy_for_self() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 28
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end