10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/placer_dsl.rb', line 10
def exec(*command)
cmd = command.flatten.join(' ')
@logger.log(:ssh_exec, "Executing command #{cmd} on remote")
@conn.exec!(cmd) do |channel, stream, data|
{:stdout => :ssh_info, :stderr => :ssh_error}.each do |s, l|
data.lines.each{ |d| @logger.log(l, d) if stream == s }
end
channel.on_request("exit-status") do |ch, data|
exit_code = data.read_long
raise "remote command: \"#{cmd}\" returned with non-zero exit code: #{exit_code}" if exit_code != 0
end
end
end
|