Sha256: e5fef79a042e7fa29642a0a973fe7b8cb725f404820111c476a758ba00235c5e

Contents?: true

Size: 1.29 KB

Versions: 18

Compression:

Stored size: 1.29 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.id) 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(org_id)
        # 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

18 entries across 18 versions & 1 rubygems

Version Path
foreman_rh_cloud-10.0.3 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-11.0.3 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.59 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-11.0.2 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-11.0.1 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-11.0.0 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.58 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-10.0.2 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.57 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-10.0.1 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.56 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.55 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.54 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.53 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.52 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-8.0.52 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-9.0.51 lib/inventory_sync/async/inventory_scheduled_sync.rb
foreman_rh_cloud-8.0.51 lib/inventory_sync/async/inventory_scheduled_sync.rb