Class: ForemanInventoryUpload::Async::GenerateReportJob

Inherits:
ShellProcess
  • Object
show all
Defined in:
lib/foreman_inventory_upload/async/generate_report_job.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ShellProcess

#clear_task_output, #logger, #progress_output, #rescue_strategy_for_self, #try_execute

Methods included from ForemanRhCloud::Async::ExponentialBackoff

#attempts_before_next_interval, #done!, #done?, #invoke_external_task, #poll_external_task, #poll_intervals, #try_execute

Methods included from AsyncHelpers

#hash_to_s

Class Method Details

.output_label(label) ⇒ Object



4
5
6
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 4

def self.output_label(label)
  "report_for_#{label}"
end

Instance Method Details

#base_folderObject



43
44
45
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 43

def base_folder
  input[:base_folder]
end

#commandObject



31
32
33
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 31

def command
  "#{rake_prefix}rake rh_cloud_inventory:report:generate"
end

#envObject



35
36
37
38
39
40
41
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 35

def env
  super.merge(
    'target' => base_folder,
    'organization_id' => organization_id,
    'hosts_filter' => hosts_filter
  )
end

#hosts_filterObject



51
52
53
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 51

def hosts_filter
  input[:hosts_filter]
end

#organization_idObject



47
48
49
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 47

def organization_id
  input[:organization_id]
end

#plan(base_folder, organization_id, disconnected, hosts_filter = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 8

def plan(base_folder, organization_id, disconnected, hosts_filter = nil)
  sequence do
    super(
      GenerateReportJob.output_label("#{organization_id}#{hosts_filter.empty? ? nil : "[#{hosts_filter.to_s.parameterize}]"}"),
      organization_id: organization_id,
      base_folder: base_folder,
      hosts_filter: hosts_filter
    )

    plan_action(
      QueueForUploadJob,
      base_folder,
      ForemanInventoryUpload.facts_archive_name(organization_id, hosts_filter),
      organization_id,
      disconnected
    )
  end
end

#rake_prefixObject



27
28
29
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 27

def rake_prefix
  'foreman-' unless Rails.env.development?
end