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

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

Instance Method Summary collapse

Instance Method Details

#resource_classObject



34
35
36
# File 'app/controllers/foreman_salt/api/v2/jobs_controller.rb', line 34

def resource_class
  ::Report
end

#uploadObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/foreman_salt/api/v2/jobs_controller.rb', line 21

def upload
  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