Class: ForemanTasksCore::SingleRunnerBatchAction

Inherits:
BatchAction
  • Object
show all
Defined in:
lib/foreman_tasks_core/single_runner_batch_action.rb

Instance Method Summary collapse

Methods inherited from BatchAction

#rescue_strategy

Instance Method Details

#check_for_errors!(optional = true) ⇒ Object



20
21
22
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 20

def check_for_errors!(optional = true)
  super unless optional
end

#finalizeObject



30
31
32
33
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 30

def finalize
  output.delete(:results)
  check_for_errors!
end

#initiateObject



15
16
17
18
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 15

def initiate
  ping suspended_action
  wait_for_sub_plans sub_plans
end

#on_finishObject



24
25
26
27
28
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 24

def on_finish
  output[:results] = sub_plans.map(&:entry_action).reduce({}) do |acc, cur|
    acc.merge(cur.execution_plan_id => cur.output)
  end
end

#plan(launcher, input_hash) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 3

def plan(launcher, input_hash)
  launcher.launch_children(self, input_hash)
  sequence do
    results = plan_self
    plan_action BatchCallback, launcher.prepare_batch(input_hash), results.output[:results]
  end
end

#rescue_strategy_for_selfObject



35
36
37
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 35

def rescue_strategy_for_self
  Dynflow::Action::Rescue::Skip
end

#run(event = nil) ⇒ Object



11
12
13
# File 'lib/foreman_tasks_core/single_runner_batch_action.rb', line 11

def run(event = nil)
  super unless event == Dynflow::Action::Skip
end