class ForemanInventoryUpload::Async::HostInventoryReportJob

Public Instance Methods

humanized_name() click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 44
def humanized_name
  _("Host inventory report job")
end
organization() click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 48
def organization
  Organization.find(input[:organization_id])
end
organization_id() click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 52
def organization_id
  input[:organization_id]
end
plan(base_folder, organization_id, hosts_filter = "", upload = true) click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 8
def plan(base_folder, organization_id, hosts_filter = "", upload = true)
  organization = Organization.find(organization_id)
  action_subject(organization)

  plan_self(
    base_folder: base_folder,
    organization_id: organization_id,
    hosts_filter: hosts_filter,
    upload: upload
  )

  sequence do
    plan_action(
      GenerateHostReport,
      base_folder,
      organization_id,
      hosts_filter
    )
    if upload
      plan_action(
        QueueForUploadJob,
        base_folder,
        ForemanInventoryUpload.facts_archive_name(organization_id, hosts_filter),
        organization_id
      )
    end

    if ForemanRhCloud.with_iop_smart_proxy?
      plan_action(
        CreateMissingInsightsFacets,
        organization_id
      )
    end
  end
end
report_file_path() click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 56
def report_file_path
  filename = ForemanInventoryUpload.facts_archive_name(input[:organization_id], input[:hosts_filter])

  if input[:upload]
    # For upload tasks, check: done folder (uploaded), uploads folder (queued), generated_reports folder (failed upload)
    [
      ForemanInventoryUpload.done_file_path(filename),
      ForemanInventoryUpload.uploads_file_path(filename),
      File.join(input[:base_folder], filename),
    ].find { |path| File.exist?(path) }
  else
    # For generate-only tasks, only check generated_reports folder
    generated_path = File.join(input[:base_folder], filename)
    File.exist?(generated_path) ? generated_path : nil
  end
end
rescue_strategy_for_self() click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 73
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end
resource_locks() click to toggle source
# File lib/foreman_inventory_upload/async/host_inventory_report_job.rb, line 4
def resource_locks
  :link
end