From e8470e4376bda36c2550ffa72e86f87d84c9db3f Mon Sep 17 00:00:00 2001 From: Ultra2D Date: Wed, 9 Mar 2016 12:01:59 +0100 Subject: Procurve filter control sequences and run `show system information`; fixes #356 --- lib/oxidized/model/procurve.rb | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 684a4b6..9095d4a 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -1,36 +1,42 @@ class Procurve < Oxidized::Model - # FIXME: this is way too unsafe - prompt /.*?(\w+# ).*/m + # some models start lines with \r + # previous command is repeated followed by "\eE", which sometimes ends up on last line + prompt /^\r?([\w -]+\eE)?([\w-]+# )$/ comment '! ' + # replace all used vt100 control sequences + expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re| + data.gsub re, '' + end + expect /Press any key to continue/ do - send ' ' - "" + send ' ' + "" end cmd :all do |cfg| cfg = cfg.each_line.to_a[1..-3].join - cfg = cfg.gsub /\r/, '' - new_cfg = '' - cfg.each_line do |line| - line.sub! /^\e.*(\e.*)/, '\1' #leave last escape - line.sub! /\e\[24;1H/, '' #remove last escape, is it always this? - new_cfg << line - end - new_cfg + cfg = cfg.gsub /^\r/, '' end cmd 'show version' do |cfg| comment cfg end + # not supported on all models cmd 'show system-information' do |cfg| cfg = cfg.split("\n")[0..-8].join("\n") comment cfg end + # not supported on all models + cmd 'show system information' do |cfg| + cfg = cfg.split("\n")[0..-8].join("\n") + comment cfg + end + cmd 'show running-config' cfg :telnet do -- cgit v1.2.1