From f2da63369fcb754e3715091cc4fd2f93db42106e Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Tue, 27 Oct 2015 14:49:52 -0400 Subject: better test framework, more specs and Travis CI --- lib/oxidized/model/junos.rb | 14 +++++++------- lib/oxidized/model/model.rb | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 0e921d2..da3af72 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+).*/, '' - cfg.gsub! /community (\S+) {/, 'community {' + cmd :secret do |cfg| + cfg.gsub!(/encrypted-password (\S+).*/, '') + cfg.gsub!(/community (\S+) {/, 'community {') 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 @@ -39,8 +39,8 @@ class JunOS < Oxidized::Model end 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..c95cc67 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 -- cgit v1.2.1 From a54574ee01060097259adc22413efe1853b83bbb Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 26 Oct 2015 14:30:48 -0400 Subject: include health and hardware info into config --- lib/oxidized/model/junos.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index da3af72..2572b93 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -20,7 +20,7 @@ class JunOS < Oxidized::Model cmd 'show configuration | display omit' - cmd 'show version' do |cfg| + cmd 'show version detail' do |cfg| @model = $1 if cfg.match(/^Model: (\S+)/) comment cfg end @@ -30,13 +30,26 @@ class JunOS < Oxidized::Model case @model when 'mx960' out << cmd('show chassis fabric reachability') { |cfg| comment cfg } + when 'mx480' + out << cmd('show chassis scb') { |cfg| comment cfg } + out << cmd('show chassis sfm detail') { |cfg| comment cfg } + out << cmd('show chassis ssb') { |cfg| comment cfg } + out << cmd('show chassis feb detail') { |cfg| comment cfg } + out << cmd('show chassis feb') { |cfg| comment cfg } + out << cmd('show chassis cfeb') { |cfg| comment cfg } end out end - cmd 'show chassis hardware' do |cfg| - comment cfg - end + cmd('show chassis environment') { |cfg| comment cfg } + cmd('show chassis firmware') { |cfg| comment cfg } + cmd('show chassis fpc detail') { |cfg| comment cfg } + cmd('show chassis hardware detail') { |cfg| comment cfg } + cmd('show chassis routing-engine') { |cfg| comment cfg } + cmd('show chassis alarms') { |cfg| comment cfg } + cmd('show system license') { |cfg| comment cfg } + cmd('show system boot-messages') { |cfg| comment cfg } + cmd('show system core-dumps') { |cfg| comment cfg } cfg :telnet do username(/^login:/) -- cgit v1.2.1 From 13d89b7e1a4f91728e528a5290779bcf4b645a6a Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 26 Oct 2015 15:02:09 -0400 Subject: strip temprature and speed measurement from chassis environment output --- lib/oxidized/model/junos.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 2572b93..6ba18ad 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -41,7 +41,11 @@ class JunOS < Oxidized::Model out end - cmd('show chassis environment') { |cfg| comment cfg } + cmd('show chassis environment') do |cfg| + cfg.gsub! /\d+ degrees.* F/, '' + cfg.gsub! /Spinning at \S+/, '' + comment cfg + end cmd('show chassis firmware') { |cfg| comment cfg } cmd('show chassis fpc detail') { |cfg| comment cfg } cmd('show chassis hardware detail') { |cfg| comment cfg } -- cgit v1.2.1 From 7312e8ef0d10d8846c69d6962e98a450e6950bc9 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 23 Nov 2015 11:23:59 -0500 Subject: use paranthesis for method call --- lib/oxidized/model/junos.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 6ba18ad..949a757 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -42,8 +42,8 @@ class JunOS < Oxidized::Model end cmd('show chassis environment') do |cfg| - cfg.gsub! /\d+ degrees.* F/, '' - cfg.gsub! /Spinning at \S+/, '' + cfg.gsub!(/\d+ degrees.* F/, '') + cfg.gsub!(/Spinning at \S+/, '') comment cfg end cmd('show chassis firmware') { |cfg| comment cfg } -- cgit v1.2.1 From 26b02bf064c76d6ef7943016c798629810986092 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 23 Nov 2015 12:41:50 -0500 Subject: include executed command into output --- lib/oxidized/model/model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/model.rb b/lib/oxidized/model/model.rb index c95cc67..ca851e3 100644 --- a/lib/oxidized/model/model.rb +++ b/lib/oxidized/model/model.rb @@ -79,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 -- cgit v1.2.1 From 6b47e7122ea9e8f470c30335d4bcb588ed279a18 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 23 Nov 2015 13:32:17 -0500 Subject: ignore frequently changing monitoring data --- lib/oxidized/model/junos.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 949a757..a02d588 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -47,9 +47,18 @@ class JunOS < Oxidized::Model comment cfg end cmd('show chassis firmware') { |cfg| comment cfg } - cmd('show chassis fpc detail') { |cfg| comment cfg } + cmd('show chassis fpc detail') do |cfg| + cfg.gsub!(/(Temperature\s+)(\d+)(.+)/, '\1\3') + cfg.gsub!(/(\s+\d+ days,)(.+seconds)/, '\1 \3') + comment cfg + end cmd('show chassis hardware detail') { |cfg| comment cfg } - cmd('show chassis routing-engine') { |cfg| comment cfg } + cmd('show chassis routing-engine') do |cfg| + cfg.gsub!(/(\S+\s+)(\d+)( percent)/, '\1\3') + cfg.gsub!(/(\s+\d+ days,)(.+seconds)/, '\1 \3') + cfg.gsub!(/(\s+)(\d+\.\d+)(\s+)(\d+\.\d+)(\s+)(\d+\.\d+)/, '\1\3\5') + comment cfg + end cmd('show chassis alarms') { |cfg| comment cfg } cmd('show system license') { |cfg| comment cfg } cmd('show system boot-messages') { |cfg| comment cfg } -- cgit v1.2.1 From d0736c757645694ed255e060c5eab45c21f9ffa6 Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Mon, 7 Dec 2015 09:22:36 -0500 Subject: bug fix --- lib/oxidized/model/junos.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index a02d588..1b641ca 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -54,7 +54,8 @@ class JunOS < Oxidized::Model end cmd('show chassis hardware detail') { |cfg| comment cfg } cmd('show chassis routing-engine') do |cfg| - cfg.gsub!(/(\S+\s+)(\d+)( percent)/, '\1\3') + cfg.gsub!(/(\S+\s+)(\d{2})( percent)/, '\1\3') + cfg.gsub!(/(\S+\s+)(\s\d{1})( percent)/, '\1\3') cfg.gsub!(/(\s+\d+ days,)(.+seconds)/, '\1 \3') cfg.gsub!(/(\s+)(\d+\.\d+)(\s+)(\d+\.\d+)(\s+)(\d+\.\d+)/, '\1\3\5') comment cfg -- cgit v1.2.1 From f79e596b571b8b5913c2b4a9dc79968a712dab7b Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Wed, 9 Dec 2015 22:34:47 -0500 Subject: keep the config output clean --- lib/oxidized/model/junos.rb | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 1b641ca..bb56481 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -20,7 +20,7 @@ class JunOS < Oxidized::Model cmd 'show configuration | display omit' - cmd 'show version detail' do |cfg| + cmd 'show version' do |cfg| @model = $1 if cfg.match(/^Model: (\S+)/) comment cfg end @@ -30,40 +30,11 @@ class JunOS < Oxidized::Model case @model when 'mx960' out << cmd('show chassis fabric reachability') { |cfg| comment cfg } - when 'mx480' - out << cmd('show chassis scb') { |cfg| comment cfg } - out << cmd('show chassis sfm detail') { |cfg| comment cfg } - out << cmd('show chassis ssb') { |cfg| comment cfg } - out << cmd('show chassis feb detail') { |cfg| comment cfg } - out << cmd('show chassis feb') { |cfg| comment cfg } - out << cmd('show chassis cfeb') { |cfg| comment cfg } end out end - cmd('show chassis environment') do |cfg| - cfg.gsub!(/\d+ degrees.* F/, '') - cfg.gsub!(/Spinning at \S+/, '') - comment cfg - end - cmd('show chassis firmware') { |cfg| comment cfg } - cmd('show chassis fpc detail') do |cfg| - cfg.gsub!(/(Temperature\s+)(\d+)(.+)/, '\1\3') - cfg.gsub!(/(\s+\d+ days,)(.+seconds)/, '\1 \3') - comment cfg - end - cmd('show chassis hardware detail') { |cfg| comment cfg } - cmd('show chassis routing-engine') do |cfg| - cfg.gsub!(/(\S+\s+)(\d{2})( percent)/, '\1\3') - cfg.gsub!(/(\S+\s+)(\s\d{1})( percent)/, '\1\3') - cfg.gsub!(/(\s+\d+ days,)(.+seconds)/, '\1 \3') - cfg.gsub!(/(\s+)(\d+\.\d+)(\s+)(\d+\.\d+)(\s+)(\d+\.\d+)/, '\1\3\5') - comment cfg - end - cmd('show chassis alarms') { |cfg| comment cfg } - cmd('show system license') { |cfg| comment cfg } - cmd('show system boot-messages') { |cfg| comment cfg } - cmd('show system core-dumps') { |cfg| comment cfg } + cmd('show chassis hardware') { |cfg| comment cfg } cfg :telnet do username(/^login:/) -- cgit v1.2.1