diff options
| author | ytti <saku@ytti.fi> | 2016-03-09 18:26:38 +0200 | 
|---|---|---|
| committer | ytti <saku@ytti.fi> | 2016-03-09 18:26:38 +0200 | 
| commit | 27ee487c9681e735de83dbd26463c07c3a91d869 (patch) | |
| tree | 204c935669016c971a3b41d95c48ccf46ef1252b /lib/oxidized/model | |
| parent | dcf06dd1ec50c91ea34b218078786fe825b46e9c (diff) | |
| parent | 51476cf2a8dd8738ebe631015c8c52ee4aea0d39 (diff) | |
Merge pull request #361 from Ultra2D/procurve-model
Procurve filter control sequences and run `show system information`
Diffstat (limited to 'lib/oxidized/model')
| -rw-r--r-- | lib/oxidized/model/procurve.rb | 37 | 
1 files changed, 25 insertions, 12 deletions
| diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 684a4b6..e667f48 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -1,36 +1,49 @@  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 :secret do |cfg| +    cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>' +    cfg.gsub! /^(snmp-server host).*/, '\\1 <configuration removed>' +    cfg.gsub! /^(radius-server host).*/, '\\1 <configuration removed>' +    cfg    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 | 
