Sha256: e4f4f2c8f6d97719d438fe0204d765b3d13393f31cb4d3faac69f0a4f34604e9

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

module InventorySync
  module Async
    class InventoryScheduledSync < ::Actions::EntryAction
      include ::Actions::RecurringAction
      include ForemanInventoryUpload::Async::DelayedStart

      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
          # perform a sequence of sync then delete in parallel for all organizations
          concurrence do
            Organization.unscoped.each do |org|
              sequence do
                plan_org_sync(org)
                plan_remove_insights_hosts(org) if Setting[:allow_auto_insights_mismatch_delete]
              end
            end
          end
        end
      end

      def plan_org_sync(org)
        plan_action InventoryFullSync, org
      end

      def plan_remove_insights_hosts
        # plan a remove hosts action with search set to empty (all records)
        plan_action(ForemanInventoryUpload::Async::RemoveInsightsHostsJob, '', org.id)
      end

      def logger
        action_logger
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_rh_cloud-8.0.50 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-8.0.49 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-8.0.48 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-8.0.47 lib/inventory_sync/async/inventory_scheduled_sync.rb