Module: Actions::Helpers::WithDelegatedAction

Includes:
WithContinuousOutput
Defined in:
app/lib/actions/helpers/with_delegated_action.rb

Instance Method Summary collapse

Methods included from WithContinuousOutput

#continuous_output, #fill_planning_errors_to_continuous_output

Instance Method Details

#continuous_output_providersObject



28
29
30
31
32
# File 'app/lib/actions/helpers/with_delegated_action.rb', line 28

def continuous_output_providers
  super.tap do |ret|
    ret << delegated_action if delegated_action.respond_to?(:fill_continuous_output)
  end
end

#delegated_actionObject



47
48
49
50
51
52
53
54
# File 'app/lib/actions/helpers/with_delegated_action.rb', line 47

def delegated_action
  # TODO: make it easier in dynflow to load action data
  delegated_step = task.execution_plan.steps.values.reverse.find do |step|
    step.action_id == input[:delegated_action_id]
  end
  return unless delegated_step
  world.persistence.load_action(delegated_step)
end

#delegated_outputObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/lib/actions/helpers/with_delegated_action.rb', line 34

def delegated_output
  return @delegated_output if @delegated_output
  action = delegated_action
  @delegated_output = case action
                      when NilClass
                        {}
                      when ::Actions::ProxyAction
                        action.proxy_output(true)
                      else
                        action.output
                      end
end

#humanized_outputObject



24
25
26
# File 'app/lib/actions/helpers/with_delegated_action.rb', line 24

def humanized_output
  delegated_output
end

#plan_delegated_action(proxy, klass, options, proxy_action_class: ::Actions::ProxyAction) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/lib/actions/helpers/with_delegated_action.rb', line 6

def plan_delegated_action(proxy, klass, options, proxy_action_class: ::Actions::ProxyAction)
  case proxy
  when :not_defined
    if klass.is_a?(String)
      raise Foreman::Exception, _('No proxy defined for execution')
    else
      delegated_action = plan_action(klass, options)
    end
  when :not_available
    raise Foreman::Exception, _('All proxies with the required feature are unavailable at the moment')
  when ::SmartProxy
    delegated_action = plan_action(proxy_action_class, proxy, klass, options)
  end

  input[:delegated_action_id] = delegated_action.id
  delegated_action
end