mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add debug option to Fog::Compute::Server#ssh
keeps display logic in Fog::SSH::Result
This commit is contained in:
parent
7ec382cf36
commit
1cf33ccc7a
1 changed files with 14 additions and 4 deletions
|
@ -42,6 +42,7 @@ module Fog
|
|||
|
||||
@address = address
|
||||
@username = username
|
||||
@debug = options.delete :debug
|
||||
@options = { :paranoid => false }.merge(options)
|
||||
end
|
||||
|
||||
|
@ -51,7 +52,7 @@ module Fog
|
|||
begin
|
||||
Net::SSH.start(@address, @username, @options) do |ssh|
|
||||
commands.each do |command|
|
||||
result = Result.new(command)
|
||||
result = Result.new(command, @debug)
|
||||
ssh.open_channel do |ssh_channel|
|
||||
ssh_channel.request_pty
|
||||
ssh_channel.exec(command) do |channel, success|
|
||||
|
@ -91,6 +92,15 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
require 'delegate'
|
||||
|
||||
class DebugString < SimpleDelegator
|
||||
def <<(add_me)
|
||||
puts add_me
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class Result
|
||||
|
||||
attr_accessor :command, :stderr, :stdout, :status
|
||||
|
@ -108,10 +118,10 @@ module Fog
|
|||
Formatador.display_line(stderr.split("\r\n"))
|
||||
end
|
||||
|
||||
def initialize(command)
|
||||
def initialize(command, debug=false)
|
||||
@command = command
|
||||
@stderr = ''
|
||||
@stdout = ''
|
||||
@stderr = debug ? DebugString.new('') : ''
|
||||
@stdout = debug ? DebugString.new('') : ''
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue