# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 49 def command @command ||= Dispatcher::Command.new(:id => input[:task_id], :host => input[:hostname], :ssh_user => 'root', :effective_user => input[:effective_user], :script => input[:script], :host_public_key => input[:host_public_key], :verify_host => input[:verify_host], :suspended_action => suspended_action) end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 75 def failed_run? output[:exit_status] != 0 end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 40 def finalize # To mark the task as a whole as failed error! "Script execution failed" if failed_run? end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 71 def finish_run(update) output[:exit_status] = update.exit_status end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 60 def init_run output[:result] = [] Proxy::RemoteExecution::Ssh.dispatcher.tell([:initialize_command, command]) suspend end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 66 def kill_run Proxy::RemoteExecution::Ssh.dispatcher.tell([:kill, command]) suspend end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 6 def plan(input) if callback = input['callback'] input[:task_id] = callback['task_id'] else input[:task_id] ||= SecureRandom.uuid end plan_with_callback(input) end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 45 def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end
# File lib/smart_proxy_remote_execution_ssh/command_action.rb, line 15 def run(event = nil) case event when nil init_run when Dispatcher::CommandUpdate update = event output[:result].concat(update.buffer_to_hash) if update.exit_status finish_run(update) else suspend end when Dynflow::Action::Cancellable::Cancel kill_run when Dynflow::Action::Skip # do nothing else raise "Unexpected event #{event.inspect}" end rescue => e action_logger.error e output[:result] << Connector::DebugData.new("#{e.class}: #{e.message}").to_hash output[:exit_status] = "PROXY_ERROR" end