Class: Actions::Base

Inherits:
Dynflow::Action
  • Object
show all
Includes:
Helpers::LifecycleLogging
Defined in:
app/lib/actions/base.rb

Direct Known Subclasses

EntryAction, ProxyAction

Instance Method Summary collapse

Methods included from Helpers::LifecycleLogging

included, #log_task_state_change

Instance Method Details

#already_running?Boolean

Returns:

  • (Boolean)


50
51
52
53
# File 'app/lib/actions/base.rb', line 50

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

#humanized_errorsObject

This method should return String or Array<String> describing the errors during the action



44
45
46
47
48
# File 'app/lib/actions/base.rb', line 44

def humanized_errors
  execution_plan.steps_in_state(:skipped, :skipping, :error).map do |step|
    step.error.message if step.error
  end.compact
end

#humanized_inputObject

This method should return String or Array<String> describing input for the task



32
33
34
# File 'app/lib/actions/base.rb', line 32

def humanized_input
  ''
end

#humanized_nameObject

This method should return humanized description of the action, e.g. “Install package”



27
28
29
# File 'app/lib/actions/base.rb', line 27

def humanized_name
  self.class.name.demodulize.underscore.humanize
end

#humanized_outputObject

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



39
40
41
# File 'app/lib/actions/base.rb', line 39

def humanized_output
  ''
end

#notify_paused(*_args) ⇒ Object



59
60
61
# File 'app/lib/actions/base.rb', line 59

def notify_paused(*_args)
  task.build_notifications.each(&:deliver!) if root_action?
end

#serializer_classObject



55
56
57
# File 'app/lib/actions/base.rb', line 55

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

#taskObject



8
9
10
# File 'app/lib/actions/base.rb', line 8

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

#task_inputObject

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



14
15
16
# File 'app/lib/actions/base.rb', line 14

def task_input
  input
end

#task_outputObject

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



22
23
24
# File 'app/lib/actions/base.rb', line 22

def task_output
  output
end