From ee2f9ab1f15a584cca44849dfa347dd773c71413 Mon Sep 17 00:00:00 2001 From: Matthew Walster Date: Thu, 7 Aug 2014 16:23:45 +0100 Subject: Use a more compatible Foundry/Brocade syntax for turning off paging Unfortunately, older Foundry/Brocade hardware doesn't support "terminal length 0" and you have to use the much clunkier "skip-page-display" instead. This especially affects older FastIron era devices. --- lib/oxidized/model/ironware.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb index e501f76..679bdea 100644 --- a/lib/oxidized/model/ironware.rb +++ b/lib/oxidized/model/ironware.rb @@ -26,7 +26,7 @@ class IronWare < Oxidized::Model end cfg :telnet, :ssh do - post_login 'terminal length 0' + post_login 'skip-page-display' pre_logout 'exit' end -- cgit v1.2.1 From 96d6c0213178241ab3170141906c152c6984e446 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Fri, 8 Aug 2014 21:25:18 +0300 Subject: Support creating session log of telnet/ssh If you have input: debug: session_log Then session_log-telnet and session_log-ssh will be created showing what the telnet/ssh saw. Helpful in model development. --- lib/oxidized/config.rb | 3 ++- lib/oxidized/input/ssh.rb | 3 +++ lib/oxidized/input/telnet.rb | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index b7fd008..ddfde81 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -29,7 +29,8 @@ module Oxidized CFGS.default.vars = {} # could be 'enable'=>'enablePW' CFGS.default.groups = {} # group level configuration - CFGS.default.input.default = 'ssh, telnet' + CFGS.default.input.default = 'ssh, telnet' + CFGS.default.input.debug = false # or String for session log file CFGS.default.input.ssh.secure = false # complain about changed certs CFGS.default.output.default = 'file' # file, git diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index e3fcede..62a31eb 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -20,6 +20,7 @@ module Oxidized @output = '' @node.model.cfg['ssh'].each { |cb| instance_exec(&cb) } secure = CFG.input.ssh.secure + @log = File.open(CFG.input.debug?.to_s + '-ssh', 'w') if CFG.input.debug? @ssh = Net::SSH.start @node.ip, @node.auth[:username], :password => @node.auth[:password], :timeout => CFG.timeout, :paranoid => secure @@ -59,12 +60,14 @@ module Oxidized Timeout::timeout(CFG.timeout) { @ssh.loop } rescue Errno::ECONNRESET, Net::SSH::Disconnect, IOError ensure + @log.close if CFG.input.debug? (@ssh.close rescue true) unless @ssh.closed? end def shell_open ssh @ses = ssh.open_channel do |ch| ch.on_data do |_ch, data| + @log.print data if CFG.input.debug? @output << data @output = @node.model.expects @output end diff --git a/lib/oxidized/input/telnet.rb b/lib/oxidized/input/telnet.rb index d52ebf0..62f361e 100644 --- a/lib/oxidized/input/telnet.rb +++ b/lib/oxidized/input/telnet.rb @@ -10,8 +10,12 @@ module Oxidized @node = node @timeout = CFG.timeout @node.model.cfg['telnet'].each { |cb| instance_exec(&cb) } - @telnet = Net::Telnet.new 'Host' => @node.ip, 'Timeout' => @timeout, - 'Model' => @node.model + + opt = { 'Host' => @node.ip, 'Timeout' => @timeout, + 'Model' => @node.model } + opt['Output_log'] = CFG.input.debug?.to_s + '-telnet' if CFG.input.debug? + + @telnet = Net::Telnet.new opt expect username @telnet.puts @node.auth[:username] expect password -- cgit v1.2.1