Class: Actions::RemoteExecution::RunProxyCommand

Inherits:
ProxyAction
  • Object
show all
Includes:
Helpers::LiveOutput, Dynflow::Action::Cancellable
Defined in:
app/lib/actions/remote_execution/run_proxy_command.rb

Instance Method Summary collapse

Methods included from Helpers::LiveOutput

#exception_to_output, #format_output

Instance Method Details

#exit_statusObject



38
39
40
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 38

def exit_status
  proxy_output && proxy_output[:exit_status]
end

#failed_run?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 33

def failed_run?
  output[:result] == 'initialization_error' ||
    (exit_status && proxy_output[:exit_status] != 0)
end

#live_outputObject



42
43
44
45
46
47
48
49
50
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 42

def live_output
  records = connection_messages
  if !task.pending?
    records.concat(finalized_output)
  else
    records.concat(current_proxy_output)
  end
  records.sort_by { |record| record['timestamp'].to_f }
end

#on_data(data) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 17

def on_data(data)
  if data[:result] == 'initialization_error'
    handle_connection_exception(data[:metadata][:exception_class]
                                 .constantize
                                 .new(data[:metadata][:exception_message]))
  else
    super(data)
    error! _('Script execution failed') if failed_run?
  end
end

#plan(proxy, hostname, script, options = {}) ⇒ Object



8
9
10
11
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 8

def plan(proxy, hostname, script, options = {})
  options = { :effective_user => nil }.merge(options)
  super(proxy, options.merge(:hostname => hostname, :script => script))
end

#proxy_action_nameObject



13
14
15
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 13

def proxy_action_name
  'Proxy::RemoteExecution::Ssh::CommandAction'
end

#rescue_strategyObject



29
30
31
# File 'app/lib/actions/remote_execution/run_proxy_command.rb', line 29

def rescue_strategy
  ::Dynflow::Action::Rescue::Skip
end