Class: ForemanInventoryUpload::Async::UploadReportJob
- Inherits:
-
ShellProcess
- Object
- Actions::EntryAction
- ShellProcess
- ForemanInventoryUpload::Async::UploadReportJob
show all
- Defined in:
- lib/foreman_inventory_upload/async/upload_report_job.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#clear_task_output, #logger, #progress_output, #rescue_strategy_for_self
#attempts_before_next_interval, #done!, #done?, #invoke_external_task, #poll_external_task, #poll_intervals
#hash_to_s
Class Method Details
.output_label(label) ⇒ Object
6
7
8
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 6
def self.output_label(label)
"upload_for_#{label}"
end
|
Instance Method Details
#certificate ⇒ Object
63
64
65
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 63
def certificate
ForemanRhCloud.with_iop_smart_proxy? ? foreman_certificate : manifest_certificate
end
|
#content_disconnected? ⇒ Boolean
92
93
94
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 92
def content_disconnected?
!Setting[:subscription_connection_enabled]
end
|
#env ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 48
def env
env_vars = super.merge(
'FILES' => filename,
'CER_PATH' => @cer_path,
'ORG_ID' => organization.label
)
http_proxy_string = ForemanRhCloud.http_proxy_string
if http_proxy_string
env_vars['http_proxy'] = http_proxy_string
env_vars['https_proxy'] = http_proxy_string
end
env_vars
end
|
#filename ⇒ Object
84
85
86
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 84
def filename
input[:filename]
end
|
#foreman_certificate ⇒ Object
77
78
79
80
81
82
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 77
def foreman_certificate
@foreman_certificate ||= {
cert: File.read(Setting[:ssl_certificate]),
key: File.read(Setting[:ssl_priv_key]),
}
end
|
#manifest_certificate ⇒ Object
67
68
69
70
71
72
73
74
75
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 67
def manifest_certificate
@manifest_certificate ||= begin
candlepin_id_certificate = organization.owner_details['upstreamConsumer']['idCert']
{
cert: candlepin_id_certificate['cert'],
key: candlepin_id_certificate['key'],
}
end
end
|
#organization ⇒ Object
88
89
90
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 88
def organization
@organization ||= Organization.find(input[:organization_id])
end
|
#plan(filename, organization_id) ⇒ Object
10
11
12
13
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 10
def plan(filename, organization_id)
label = UploadReportJob.output_label(organization_id)
super(label, filename: filename, organization_id: organization_id)
end
|
#try_execute ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/foreman_inventory_upload/async/upload_report_job.rb', line 15
def try_execute
if content_disconnected?
progress_output do |progress_output|
progress_output.write_line("Report was not moved and upload was canceled because connection to Insights is not enabled. Report location: #{filename}.")
progress_output.status = "Task aborted, exit 1"
done!
end
return
end
unless organization.owner_details&.fetch('upstreamConsumer')&.fetch('idCert')
logger.info("Skipping organization '#{organization}', no candlepin certificate defined.")
progress_output do |progress_output|
progress_output.write_line("Skipping organization #{organization}, no candlepin certificate defined.")
progress_output.status = "Task aborted, exit 1"
done!
end
return
end
Tempfile.create([organization.name, '.pem']) do |cer_file|
cer_file.write(certificate[:cert])
cer_file.write(certificate[:key])
cer_file.flush
@cer_path = cer_file.path
super
end
end
|