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/telnet.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/telnet.rb')
-rw-r--r-- | lib/oxidized/input/telnet.rb | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb index 26755ca..0ae6877 100644 --- a/lib/oxidized/input/telnet.rb +++ b/lib/oxidized/input/telnet.rb @@ -2,6 +2,7 @@ module Oxidized require 'net/telnet' require 'oxidized/input/cli' class Telnet < Input + RescueFail = [] include CLI attr_reader :telnet @@ -9,28 +10,20 @@ module Oxidized @node = node @timeout = CFG.timeout @node.model.cfg['telnet'].each { |cb| instance_exec &cb } - begin - @telnet = Net::Telnet.new 'Host' => @node.ip, 'Waittime' => @timeout, - 'Model' => @node.model - expect username - @telnet.puts @node.auth[:username] - expect password - @telnet.puts @node.auth[:password] - expect @node.prompt - rescue Timeout::Error, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EPIPE, Errno::EHOSTUNREACH - return false - end + @telnet = Net::Telnet.new 'Host' => @node.ip, 'Waittime' => @timeout, + 'Model' => @node.model + expect username + @telnet.puts @node.auth[:username] + expect password + @telnet.puts @node.auth[:password] + expect @node.prompt end def cmd cmd, expect=@node.prompt Log.debug "Telnet: #{cmd} @#{@node.name}" args = { 'String' => cmd } args.merge!({ 'Match' => expect, 'Timeout' => @timeout }) if expect - begin - @telnet.cmd args - rescue Timeout::Error, Errno::ECONNRESET, Errno::EPIPE - return false - end + @telnet.cmd args end def send data |