class ForemanInventoryUpload::Async::GenerateAllReportsJob

Public Instance Methods

logger() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 40
def logger
  action_logger
end
plan() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 7
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

  after_delay do
    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
        disconnected = false
        plan_generate_report(ForemanInventoryUpload.generated_reports_folder, organization, disconnected)
      else
        logger.info("Skipping automatic uploads for organization #{organization.name}, too many hosts (#{total_hosts}/#{ForemanInventoryUpload.max_org_size})")
      end
    end.compact
  end
end
plan_generate_report(folder, organization, disconnected) click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 36
def plan_generate_report(folder, organization, disconnected)
  plan_action(ForemanInventoryUpload::Async::GenerateReportJob, folder, organization.id, disconnected)
end
rescue_strategy_for_self() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 32
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end