Sha256: d9fd6fa033ec964318c25c8e849d41df3b45a4bfe6f4f79581270834e10521de

Contents?: true

Size: 1.89 KB

Versions: 20

Compression:

Stored size: 1.89 KB

Contents

module Actions
  class Base < Dynflow::Action

    def task
      @task ||= ::ForemanTasks::Task::DynflowTask.where(:external_id => execution_plan_id).first!
    end

    # This method says what data form input gets into the task details in Rest API
    # By default, it sends the whole input there.
    def task_input
      self.input
    end

    # This method says what data form output gets into the task details in Rest API
    # It should aggregate the important data that are worth to propagate to Rest API,
    # perhaps also aggraget data from subactions if needed (using +all_actions+) method
    # of Dynflow::Action::Presenter
    def task_output
      self.output
    end

    # This method should return humanized description of the action, e.g. "Install package"
    def humanized_name
      self.class.name.demodulize.underscore.humanize
    end

    # This method should return String or Array<String> describing input for the task
    def humanized_input
      if task_input.blank?
        ""
      else
        task_input.pretty_inspect
      end
    end

    # This method should return String describing output for the task.
    # It should aggregate the data from subactions as well and it's used for humanized
    # description of restuls of the action
    def humanized_output
      if task_output.blank?
        ""
      else
        task_output.pretty_inspect
      end
    end

    # This method should return String or Array<String> describing the errors during the action
    def humanized_errors
      execution_plan.steps_in_state(:skipped, :skipping, :error).map do |step|
        step.error.message if step.error
      end.compact
    end

    def already_running?
      ForemanTasks::Task::DynflowTask.for_action(self.class).
        running.where('external_id != ?', execution_plan_id).any?
    end

    def serializer_class
      ::Actions::Serializers::ActiveRecordSerializer
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman-tasks-0.8.6 app/lib/actions/base.rb
foreman-tasks-0.8.5 app/lib/actions/base.rb
foreman-tasks-0.8.4 app/lib/actions/base.rb
foreman-tasks-0.8.3 app/lib/actions/base.rb
foreman-tasks-0.8.2 app/lib/actions/base.rb
foreman-tasks-0.8.1 app/lib/actions/base.rb
foreman-tasks-0.8.0 app/lib/actions/base.rb
foreman-tasks-0.7.20 app/lib/actions/base.rb
foreman-tasks-0.7.19 app/lib/actions/base.rb
foreman-tasks-0.7.18 app/lib/actions/base.rb
foreman-tasks-0.7.17 app/lib/actions/base.rb
foreman-tasks-0.7.16 app/lib/actions/base.rb
foreman-tasks-0.7.15 app/lib/actions/base.rb
foreman-tasks-0.7.14 app/lib/actions/base.rb
foreman-tasks-0.7.13 app/lib/actions/base.rb
foreman-tasks-0.7.12 app/lib/actions/base.rb
foreman-tasks-0.7.11 app/lib/actions/base.rb
foreman-tasks-0.7.10 app/lib/actions/base.rb
foreman-tasks-0.7.9 app/lib/actions/base.rb
foreman-tasks-0.7.8 app/lib/actions/base.rb