class InventorySync::Async::InventoryScheduledSync

Public Instance Methods

logger() click to toggle source
# File lib/inventory_sync/async/inventory_scheduled_sync.rb, line 38
def logger
  action_logger
end
plan() click to toggle source
# File lib/inventory_sync/async/inventory_scheduled_sync.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
    # 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
plan_org_sync(org) click to toggle source
# File lib/inventory_sync/async/inventory_scheduled_sync.rb, line 29
def plan_org_sync(org)
  plan_action InventoryFullSync, org
end
plan_remove_insights_hosts(org_id) click to toggle source
# File lib/inventory_sync/async/inventory_scheduled_sync.rb, line 33
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
rescue_strategy_for_self() click to toggle source
# File lib/inventory_sync/async/inventory_scheduled_sync.rb, line 42
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end