Class: ForemanSalt::Api::V2::JobsController

Inherits:
BaseController
  • Object
show all
Includes:
Foreman::Controller::FilterParameters, Foreman::Controller::SmartProxyAuth
Defined in:
app/controllers/foreman_salt/api/v2/jobs_controller.rb

Instance Method Summary collapse

Instance Method Details

#resource_classObject



38
39
40
# File 'app/controllers/foreman_salt/api/v2/jobs_controller.rb', line 38

def resource_class
  ::Report
end

#uploadObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/foreman_salt/api/v2/jobs_controller.rb', line 24

def upload
  params[:job].permit!
  Rails.logger.info("Processing job #{params[:job][:job_id]} from Salt.")
  case params[:job][:function]
  when 'state.highstate'
    task = ForemanTasks.async_task(::Actions::ForemanSalt::ReportImport, params[:job], detected_proxy.try(:id))
    render json: { task_id: task.id }
  else
    render json: { message: 'Unsupported function' }, status: :unprocessable_entity
  end
rescue ::Foreman::Exception => e
  render json: { message: e.to_s }, status: :unprocessable_entity
end