Class: ForemanInventoryUpload::UploadsController

Inherits:
ApplicationController
  • Object
show all
Includes:
InventoryUpload::ReportActions
Defined in:
app/controllers/foreman_inventory_upload/uploads_controller.rb

Instance Method Summary collapse

Methods included from InventoryUpload::ReportActions

#report_file, #start_report_generation

Instance Method Details

#download_fileObject



14
15
16
17
18
# File 'app/controllers/foreman_inventory_upload/uploads_controller.rb', line 14

def download_file
  filename, file = report_file(params[:organization_id])

  send_file file, disposition: 'attachment', filename: filename
end

#enable_cloud_connectorObject



20
21
22
23
24
25
26
# File 'app/controllers/foreman_inventory_upload/uploads_controller.rb', line 20

def enable_cloud_connector
  # Set the autoupload to true, since it's required by the feature.
  Setting[:allow_auto_inventory_upload] = true

  cloud_connector = ForemanRhCloud::CloudConnector.new
  render json: cloud_connector.install.to_json
end

#lastObject



5
6
7
8
9
10
11
12
# File 'app/controllers/foreman_inventory_upload/uploads_controller.rb', line 5

def last
  label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:organization_id])
  output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output

  render json: {
    output: output,
  }, status: :ok
end