Class: ForemanInventoryUpload::Async::GenerateAllReportsJob
  
  
  
  
  
    - Inherits:
 
    - 
      Actions::EntryAction
      
        
          - Object
 
          
            - Actions::EntryAction
 
          
            - ForemanInventoryUpload::Async::GenerateAllReportsJob
 
          
        
        show all
      
     
  
  
  
  
  
  
  
      - Includes:
 
      - Actions::RecurringAction, DelayedStart
 
  
  
  
  
  
  
    - Defined in:
 
    - lib/foreman_inventory_upload/async/generate_all_reports_job.rb
 
  
  
 
  Constant Summary
  
  
  DelayedStart::START_WINDOW
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #after_delay, #humanized_name
  
  
  
  
    Instance Method Details
    
      
  
  
    #logger  ⇒ Object 
  
  
  
  
    
      
40
41
42 
     | 
    
      # File 'lib/foreman_inventory_upload/async/generate_all_reports_job.rb', line 40
def logger
  action_logger
end 
     | 
  
 
    
      
  
  
    #plan  ⇒ Object 
  
  
  
  
    
      
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 
     | 
    
      # File 'lib/foreman_inventory_upload/async/generate_all_reports_job.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
    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
        disconnected = false
        plan_generate_report(ForemanInventoryUpload.generated_reports_folder, organization, disconnected)
      else
        logger.info("Skipping automatic uploads for organization #{organization.name}, too many hosts (#{total_hosts}/#{ForemanInventoryUpload.max_org_size})")
      end
    end.compact
  end
end
     | 
  
 
    
      
  
  
    #plan_generate_report(folder, organization, disconnected)  ⇒ Object 
  
  
  
  
    
      
36
37
38 
     | 
    
      # File 'lib/foreman_inventory_upload/async/generate_all_reports_job.rb', line 36
def plan_generate_report(folder, organization, disconnected)
  plan_action(ForemanInventoryUpload::Async::GenerateReportJob, folder, organization.id, disconnected)
end 
     | 
  
 
    
      
  
  
    #rescue_strategy_for_self  ⇒ Object 
  
  
  
  
    
      
32
33
34 
     | 
    
      # File 'lib/foreman_inventory_upload/async/generate_all_reports_job.rb', line 32
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end 
     |