Class: InventorySync::Async::InventoryScheduledSync

Inherits:
Actions::EntryAction
  • Object
show all
Includes:
Actions::RecurringAction, ForemanInventoryUpload::Async::DelayedStart
Defined in:
lib/inventory_sync/async/inventory_scheduled_sync.rb

Constant Summary

Constants included from ForemanInventoryUpload::Async::DelayedStart

ForemanInventoryUpload::Async::DelayedStart::START_WINDOW

Instance Method Summary collapse

Methods included from ForemanInventoryUpload::Async::DelayedStart

#after_delay, #humanized_name

Instance Method Details

#loggerObject



46
47
48
# File 'lib/inventory_sync/async/inventory_scheduled_sync.rb', line 46

def logger
  action_logger
end

#planObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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

  if ForemanRhCloud.with_iop_smart_proxy?
    plan_self # so that 'run' runs
  else
    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
end

#plan_org_sync(org) ⇒ Object



33
34
35
# File 'lib/inventory_sync/async/inventory_scheduled_sync.rb', line 33

def plan_org_sync(org)
  plan_action InventoryFullSync, org
end

#plan_remove_insights_hosts(org_id) ⇒ Object



41
42
43
44
# File 'lib/inventory_sync/async/inventory_scheduled_sync.rb', line 41

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_selfObject



50
51
52
# File 'lib/inventory_sync/async/inventory_scheduled_sync.rb', line 50

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

#runObject



37
38
39
# File 'lib/inventory_sync/async/inventory_scheduled_sync.rb', line 37

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