Sha256: 6c4ead7cf06db5e5440440be1023473bc047a09d6637da2b8805f9848eb83bb0

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 KB

Contents

module ForemanInventoryUpload
  module Async
    class GenerateAllReportsJob < ::Actions::EntryAction
      include ::Actions::RecurringAction

      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

      def rescue_strategy_for_self
        Dynflow::Action::Rescue::Fail
      end

      def plan_generate_report(folder, organization)
        plan_action(ForemanInventoryUpload::Async::GenerateReportJob, folder, organization.id)
      end

      def logger
        action_logger
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
foreman_rh_cloud-5.0.46 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-5.0.45 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-5.0.44 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-5.0.43 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-6.0.42.2 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-6.0.42.1 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-6.0.43 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-5.0.42 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-6.0.42 lib/foreman_inventory_upload/async/generate_all_reports_job.rb
foreman_rh_cloud-5.0.41 lib/foreman_inventory_upload/async/generate_all_reports_job.rb