diff options
author | Saku Ytti <saku@ytti.fi> | 2014-02-07 10:36:50 +0200 |
---|---|---|
committer | Saku Ytti <saku@ytti.fi> | 2014-02-07 10:36:50 +0200 |
commit | 028bada99a02f2bc9b5b4409f09715ca49858675 (patch) | |
tree | 716c4f118321cfadbf3c89f375329e44a4039aa3 /lib/oxidized/input/ssh.rb | |
parent | f2acb9455edae1bc1c80de28af2362da9da206bf (diff) |
Ignore ssh keys, change input exceptions
Now input ssh has configuration secure which is false by default,
meaning we don't care about changing keys. It breaks ssh security model
but rancid does it too.
Also input models error handling is now mostly moved to node.rb for
centralized handling + logging. With input models only defining which
errors they want to receover from.
Diffstat (limited to 'lib/oxidized/input/ssh.rb')
-rw-r--r-- | lib/oxidized/input/ssh.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index dc90354..b060418 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -2,6 +2,10 @@ module Oxidized require 'net/ssh' require 'oxidized/input/cli' class SSH < Input + RescueFail = [ + Net::SSH::Disconnect, + Net::SSH::AuthenticationFailed, + ] include CLI class NoShell < StandardError; end @@ -9,14 +13,12 @@ module Oxidized @node = node @output = '' @node.model.cfg['ssh'].each { |cb| instance_exec &cb } - begin - @ssh = Net::SSH.start @node.ip, @node.auth[:username], - :password => @node.auth[:password], :timeout => CFG.timeout - rescue Timeout::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EHOSTUNREACH, Net::SSH::Disconnect - return false - end + secure = CFG.input[:ssh][:secure] + @ssh = Net::SSH.start @node.ip, @node.auth[:username], + :password => @node.auth[:password], :timeout => CFG.timeout, + :paranoid => secure open_shell @ssh unless @exec - not @ssh.closed? + @ssh and not @ssh.closed? end def cmd cmd, expect=@node.prompt |