Sha256: 301c8e5a113775a7721e78752c29db14538bb6eeaaf47825e47410edc4b48ef3

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

class JobInvocationsController < ApplicationController
  include Foreman::Controller::AutoCompleteSearch

  def new
    @composer = JobInvocationComposer.new.compose_from_params(
      :host_ids => params[:host_ids],
      :targeting => {
        :targeting_type => Targeting::STATIC_TYPE,
        :bookmark_id => params[:bookmark_id]
      })
  end

  def rerun
    job_invocation = resource_base.find(params[:id])
    @composer = JobInvocationComposer.new.compose_from_invocation(job_invocation)

    if params[:failed_only]
      host_ids = job_invocation.failed_host_ids
      @composer.search_query = @composer.targeting.build_query_from_hosts(host_ids)
    end

    render :action => 'new'
  end

  def create
    @composer = JobInvocationComposer.new.compose_from_params(params)
    if @composer.save
      @task = ForemanTasks.async_task(::Actions::RemoteExecution::RunHostsJob, @composer.job_invocation)
      redirect_to job_invocation_path(@composer.job_invocation)
    else
      render :action => 'new'
    end
  end

  def show
    @job_invocation = resource_base.find(params[:id])
  end

  def index
    @job_invocations = resource_base.search_for(params[:search]).paginate(:page => params[:page]).order('id DESC')
  end

  # refreshes the form
  def refresh
    @composer = JobInvocationComposer.new.compose_from_params(params)
  end

  private

  def action_permission
    case params[:action]
      when 'rerun'
        'create'
      else
        super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_remote_execution-0.0.6 app/controllers/job_invocations_controller.rb
foreman_remote_execution-0.0.5 app/controllers/job_invocations_controller.rb