Sha256: affb7691a1f226d620ffc92c98e9514be0c11748cf0c58780cf212e2924bf291

Contents?: true

Size: 1.34 KB

Versions: 46

Compression:

Stored size: 1.34 KB

Contents

module Katello
  class Api::V2::HostTracerController < Api::V2::ApiController
    before_action :find_host

    resource_description do
      api_version 'v2'
      api_base_url "/api"
    end

    api :GET, "/hosts/:host_id/traces", N_("List services that need restarting on the host")
    param :host_id, :number, :required => true, :desc => N_("ID of the host")
    def index
      collection = scoped_search(index_relation, :application, :asc, :resource_class => ::Katello::HostTracer)
      respond_for_index(:collection => collection)
    end

    api :PUT, "/hosts/:host_id/traces/resolve", N_("Resolve Traces")
    param :host_id, :number, :required => true, :desc => N_("ID of the host")
    param :trace_ids, Array, :required => true, :desc => N_("Array of Trace IDs")
    def resolve
      traces = @host.host_traces.resolvable.where(id: params[:trace_ids])
      fail HttpErrors::BadRequest, _("The requested traces were not found for this host") if traces.empty?

      result = Katello::HostTraceManager.resolve_traces(traces)

      task = ForemanTasks::Task.find(result.first.task_id)

      respond_for_async(resource: task)
    end

    protected

    def index_relation
      @host.host_traces
    end

    private

    def find_host
      @host = resource_finder(::Host::Managed.authorized(:view_hosts, ::Host::Managed), params[:host_id])
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
katello-4.2.2 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.2.1 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.2.0.1 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.1.4 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.0.3 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.2.0.1.rc3 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-3.18.5 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.2.0.1.rc2 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.2.0.rc2 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.1.3 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.2.0.rc1 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.0.2.1 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.1.2.1 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.0.2 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.1.2 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-3.18.4 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.1.1 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.1.0 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-4.0.1.2 app/controllers/katello/api/v2/host_tracer_controller.rb
katello-3.18.3.1 app/controllers/katello/api/v2/host_tracer_controller.rb