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



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

def base_folder
  input[:base_folder]
end

#commandObject



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

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

#content_disconnected?(disconnected) ⇒ Boolean

Returns:

  • (Boolean)


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

def content_disconnected?(disconnected)
  disconnected || !Setting[:subscription_connection_enabled]
end

#envObject



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

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

#hosts_filterObject



56
57
58
# File 'lib/foreman_inventory_upload/async/generate_report_job.rb', line 56

def hosts_filter
  input[:hosts_filter]
end

#organization_idObject



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

def organization_id
  input[:organization_id]
end

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



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

def plan(base_folder, organization_id, disconnected = false, 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
    )

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

#rake_prefixObject



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

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