Class: PreupgradeReport

Inherits:
Report
  • Object
show all
Defined in:
app/models/preupgrade_report.rb

Class Method Summary collapse

Class Method Details

.create_report(host, data, job_invocation_id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/preupgrade_report.rb', line 9

def self.create_report(host, data, job_invocation_id)
  # We don't have specific permissions for the Preupgrade leapp reports,
  # so we need to skip the permission check for non-admin users.
  # The user is still required to have permission to run the job and view the hosts.
  skip_permission_check do
    report = PreupgradeReport.create  host: host, status: 0,
                                      job_invocation_id: job_invocation_id,
                                      reported_at: DateTime.now.utc

    data['entries']&.each do |entry|
      PreupgradeReportEntry.create! entry_params(report, entry, host, data)
    end
  end
end

.entry_params(report, entry, host, data) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/preupgrade_report.rb', line 24

def self.entry_params(report, entry, host, data)
  { preupgrade_report: report,
    host_id: host.id,
    hostname: host.name,
    title: entry['title'],
    actor: entry['actor'],
    audience: entry['audience'],
    severity: entry['severity'],
    leapp_run_id: data['leapp_run_id'],
    summary: entry['summary'],
    tags: entry['tags'],
    flags: entry['flags'],
    detail: entry['detail'] }
end