diff options
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r-- | lib/oxidized/model/junos.rb | 18 | ||||
-rw-r--r-- | lib/oxidized/model/model.rb | 5 |
2 files changed, 11 insertions, 12 deletions
diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 0e921d2..bb56481 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -3,7 +3,7 @@ class JunOS < Oxidized::Model comment '# ' def telnet - @input.class.to_s.match /Telnet/ + @input.class.to_s.match(/Telnet/) end cmd :all do |cfg| @@ -12,16 +12,16 @@ class JunOS < Oxidized::Model cfg.lines.map { |line| line.rstrip }.join("\n") + "\n" end - cmd :secret do |cfg| - cfg.gsub! /encrypted-password (\S+).*/, '<secret removed>' - cfg.gsub! /community (\S+) {/, 'community <hidden> {' + cmd :secret do |cfg| + cfg.gsub!(/encrypted-password (\S+).*/, '<secret removed>') + cfg.gsub!(/community (\S+) {/, 'community <hidden> {') cfg end cmd 'show configuration | display omit' cmd 'show version' do |cfg| - @model = $1 if cfg.match /^Model: (\S+)/ + @model = $1 if cfg.match(/^Model: (\S+)/) comment cfg end @@ -34,13 +34,11 @@ class JunOS < Oxidized::Model out end - cmd 'show chassis hardware' do |cfg| - comment cfg - end + cmd('show chassis hardware') { |cfg| comment cfg } cfg :telnet do - username /^login:/ - password /^Password:/ + username(/^login:/) + password(/^Password:/) end cfg :ssh do diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index e0e3941..ca851e3 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -11,7 +11,8 @@ module Oxidized klass.instance_variable_set '@cfg', Hash.new { |h,k| h[k] = [] } klass.instance_variable_set '@procs', Hash.new { |h,k| h[k] = [] } klass.instance_variable_set '@expect', [] - klass.const_set :CFG, CFG + klass.instance_variable_set '@comment', nil + klass.instance_variable_set '@prompt', nil end def comment _comment='# ' return @comment if @comment @@ -78,7 +79,7 @@ module Oxidized attr_accessor :input, :node def cmd string, &block - out = @input.cmd string + out = "====================== #{string} ======================\n" + @input.cmd(string) return false unless out self.class.cmds[:all].each do |all_block| out = instance_exec Oxidized::String.new(out), string, &all_block |