class ForemanInventoryUpload::Async::GenerateAllReportsJob

Public Instance Methods

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

  if ForemanRhCloud.with_iop_smart_proxy?
    plan_self # so that 'run' runs
  else
    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
end
plan_generate_report(folder, organization, disconnected) click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 44
def plan_generate_report(folder, organization, disconnected)
  plan_action(ForemanInventoryUpload::Async::HostInventoryReportJob, 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 40
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end
run() click to toggle source
# File lib/foreman_inventory_upload/async/generate_all_reports_job.rb, line 36
def run
  output[:status] = _('The scheduled process is disabled because this Foreman is configured with a local IoP Smart Proxy.') if ForemanRhCloud.with_iop_smart_proxy?
end