From fd1b2c2ac903b3a8e2578a4ca0f48a61309a0493 Mon Sep 17 00:00:00 2001 From: Ilya Demyanov Date: Sun, 31 Dec 2017 09:19:49 +0300 Subject: Create snr.rb --- lib/oxidized/model/snr.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/oxidized/model/snr.rb (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/snr.rb b/lib/oxidized/model/snr.rb new file mode 100644 index 0000000..3f1fab5 --- /dev/null +++ b/lib/oxidized/model/snr.rb @@ -0,0 +1,14 @@ +class SNR < Oxidized::Model + + comment '!' + + cmd 'show running-config' do |cfg| + cfg = cfg.each_line.to_a[1..-1] + end + + cfg :ssh do + post_login 'terminal length 0' + pre_logout 'exit' + end + +end -- cgit v1.2.1 From 6890754f0a579fc9be3912113dcfe510b2837f7c Mon Sep 17 00:00:00 2001 From: CppMonkey Date: Thu, 1 Feb 2018 17:39:00 +0000 Subject: Initial commit for SSH/Telnet on Xyzel XGS4600 series --- lib/oxidized/model/zynoscli.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/oxidized/model/zynoscli.rb (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/zynoscli.rb b/lib/oxidized/model/zynoscli.rb new file mode 100644 index 0000000..9f29a16 --- /dev/null +++ b/lib/oxidized/model/zynoscli.rb @@ -0,0 +1,35 @@ +class ZyNOSCLI < Oxidized::Model + + # Used in Zyxel DSLAMs, such as SAM1316 + + # Typical prompt "XGS4600#" + prompt /^([\w.@()-]+[#>]\s\e7)$/ + comment ';; ' + + cmd :all do |cfg| + cfg.gsub! /^.*\e7/, '' + end + + cmd 'show running-config' + + cfg :telnet do + username /^User name:/i + password /^Password:/i + end + + cfg :telnet, :ssh do + if vars :enable + post_login do + send "enable\n" + # Interpret enable: true as meaning we won't be prompted for a password + unless vars(:enable).is_a? TrueClass + expect /[pP]assword:\s?$/ + send vars(:enable) + "\n" + end + expect /^.+[#]$/ + end + end + pre_logout 'exit' + end + +end -- cgit v1.2.1 From 97aa0535a0c8c237c1ccb7a1683d5f6faa1f0339 Mon Sep 17 00:00:00 2001 From: CppMonkey Date: Tue, 20 Mar 2018 09:53:41 +0000 Subject: Added more commands Shows more details. Confirms stacking config (Ring/Chain) Allows tracking of firmware on ras0 and ras1 --- lib/oxidized/model/zynoscli.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/zynoscli.rb b/lib/oxidized/model/zynoscli.rb index 9f29a16..ae64b04 100644 --- a/lib/oxidized/model/zynoscli.rb +++ b/lib/oxidized/model/zynoscli.rb @@ -1,5 +1,4 @@ class ZyNOSCLI < Oxidized::Model - # Used in Zyxel DSLAMs, such as SAM1316 # Typical prompt "XGS4600#" @@ -9,6 +8,9 @@ class ZyNOSCLI < Oxidized::Model cmd :all do |cfg| cfg.gsub! /^.*\e7/, '' end + cmd 'show stacking' + + cmd 'show version' cmd 'show running-config' @@ -31,5 +33,4 @@ class ZyNOSCLI < Oxidized::Model end pre_logout 'exit' end - end -- cgit v1.2.1 From 343cf3227cafe4a7de4a7be5934163eb6bd2dba9 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Tue, 20 Mar 2018 23:17:29 +0100 Subject: expand dcnos model --- lib/oxidized/model/dcnos.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index 5a39e2b..4a33fa0 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -12,6 +12,14 @@ class DCNOS < Oxidized::Model comment cfg end + cmd 'show boot-files' do |cfg| + comment cfg + end + + cmd 'show flash' do |cfg| + comment cfg + end + cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[1..-1] end -- cgit v1.2.1 From 2d8e40344a05ac16869941c19dbcd6df8ddac80c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Tue, 20 Mar 2018 23:38:23 +0100 Subject: better comments --- lib/oxidized/model/dcnos.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index 4a33fa0..c6b2e36 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -6,7 +6,7 @@ class DCNOS < Oxidized::Model - comment '!' + comment '! ' cmd 'show version' do |cfg| comment cfg -- cgit v1.2.1 From ff0a42cdfd2bdb34d0852a0d85f63825a44fdf1b Mon Sep 17 00:00:00 2001 From: James Hannah Date: Wed, 21 Mar 2018 09:02:38 +0000 Subject: Alter DNOS config. Remove constantly changing info Gsub out the uptime which changes constantly, and remove the output of "show system" which duplicates the info from "show version" and contains fan speed data which isn't helpful. --- lib/oxidized/model/dnos.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/dnos.rb b/lib/oxidized/model/dnos.rb index 5c3cd53..22e1876 100644 --- a/lib/oxidized/model/dnos.rb +++ b/lib/oxidized/model/dnos.rb @@ -6,6 +6,7 @@ class DNOS < Oxidized::Model cmd :all do |cfg| cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, '' + cfg.gsub! /^Dell Networking OS uptime is\s.+/, '' # Omit constantly changing uptime info cfg.each_line.to_a[2..-2].join end @@ -27,10 +28,6 @@ class DNOS < Oxidized::Model comment cfg end - cmd 'show system' do |cfg| - comment cfg - end - cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[3..-1].join cfg -- cgit v1.2.1 From 4ba96c79f7eaf5dd9c02c9488d77a5c896c96d8c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Fri, 23 Mar 2018 09:24:38 +0100 Subject: yield cfg for clarity --- lib/oxidized/model/dcnos.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index c6b2e36..f53bc0d 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -21,7 +21,8 @@ class DCNOS < Oxidized::Model end cmd 'show running-config' do |cfg| - cfg = cfg.each_line.to_a[1..-1] + cfg = cfg.each_line.to_a[1..-1].join + cfg end cfg :telnet do -- cgit v1.2.1 From b2fcf887b3ea7e85e916ec7265a494a6efbf8fa7 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Thu, 5 Apr 2018 14:23:20 +0200 Subject: strip uptime info from show version --- lib/oxidized/model/dcnos.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index f53bc0d..ec0c7f6 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -9,6 +9,7 @@ class DCNOS < Oxidized::Model comment '! ' cmd 'show version' do |cfg| + cfg = cfg.gsub! /^(Uptime is ).*/, '' comment cfg end -- cgit v1.2.1 From b54a5e211f2127d9397e6d43c30fd47de33ee5a5 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Thu, 5 Apr 2018 15:29:00 +0200 Subject: unspeakable things took place in original PR, correcting model --- lib/oxidized/model/dcnos.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb index ec0c7f6..8506280 100644 --- a/lib/oxidized/model/dcnos.rb +++ b/lib/oxidized/model/dcnos.rb @@ -8,8 +8,12 @@ class DCNOS < Oxidized::Model comment '! ' + cmd :all do |cfg| + cfg.each_line.to_a[1..-1].join + end + cmd 'show version' do |cfg| - cfg = cfg.gsub! /^(Uptime is ).*/, '' + cfg.gsub! /\s(Uptime is).*/, '' comment cfg end @@ -22,7 +26,6 @@ class DCNOS < Oxidized::Model end cmd 'show running-config' do |cfg| - cfg = cfg.each_line.to_a[1..-1].join cfg end -- cgit v1.2.1 From f3c489be3d747af4608234fb55d93d8d3e037470 Mon Sep 17 00:00:00 2001 From: Martin Overgaard Hansen Date: Sat, 7 Apr 2018 21:34:18 +0200 Subject: Allowed prompt to contain hyphen --- lib/oxidized/model/aricentiss.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 8821801..14f8502 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -5,7 +5,7 @@ class AricentISS < Oxidized::Model - prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) + prompt (/^(\e\[27m)?[ \r]*[\w-]+# ?$/) cfg :ssh do # "pagination" was misspelled in some (earlier) versions (at least 1.0.16-9) -- cgit v1.2.1 From a4bd3e5ca5ab747fdbf2bd876d7be7a947e74f46 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sun, 8 Apr 2018 00:35:47 +0200 Subject: eliminate inverse methods from models --- lib/oxidized/model/aosw.rb | 2 +- lib/oxidized/model/asa.rb | 2 +- lib/oxidized/model/comware.rb | 2 +- lib/oxidized/model/firewareos.rb | 2 +- lib/oxidized/model/powerconnect.rb | 4 ++-- lib/oxidized/model/procurve.rb | 2 +- lib/oxidized/model/routeros.rb | 2 +- lib/oxidized/model/vrp.rb | 2 +- lib/oxidized/model/zhoneolt.rb | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb index 71fde2e..3397305 100644 --- a/lib/oxidized/model/aosw.rb +++ b/lib/oxidized/model/aosw.rb @@ -40,7 +40,7 @@ class AOSW < Oxidized::Model end cmd 'show version' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /(Switch|AP) uptime/i } + cfg = cfg.each_line.reject { |line| line.match /(Switch|AP) uptime/i } rstrip_cfg comment cfg.join end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index 9df4206..bea0705 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -27,7 +27,7 @@ class ASA < Oxidized::Model cmd 'show version' do |cfg| # avoid commits due to uptime / ixo-router01 up 2 mins 28 secs / ixo-router01 up 1 days 2 hours - cfg = cfg.each_line.select { |line| not line.match /(\s+up\s+\d+\s+)|(.*days.*)/ } + cfg = cfg.each_line.reject { |line| line.match /(\s+up\s+\d+\s+)|(.*days.*)/ } cfg = cfg.join comment cfg end diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb index a5b7190..0ba26d5 100644 --- a/lib/oxidized/model/comware.rb +++ b/lib/oxidized/model/comware.rb @@ -47,7 +47,7 @@ class Comware < Oxidized::Model end cmd 'display version' do |cfg| - cfg = cfg.each_line.select {|l| not l.match /uptime/i }.join + cfg = cfg.each_line.reject { |l| l.match /uptime/i }.join comment cfg end diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb index 1b3d07c..31770dc 100644 --- a/lib/oxidized/model/firewareos.rb +++ b/lib/oxidized/model/firewareos.rb @@ -15,7 +15,7 @@ class FirewareOS < Oxidized::Model cmd 'show sysinfo' do |cfg| # avoid commits due to uptime - cfg = cfg.each_line.select { |line| not line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ } + cfg = cfg.each_line.reject { |line| line.match /(.*time.*)|(.*memory.*)|(.*cpu.*)/ } cfg = cfg.join comment cfg end diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index f602a36..ca91e60 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -22,7 +22,7 @@ class PowerConnect < Oxidized::Model if (@stackable.nil?) @stackable = true if cfg.match /(U|u)nit\s/ end - cfg = cfg.split("\n").select { |line| not line[/Up\sTime/] } + cfg = cfg.split("\n").reject { |line| line[/Up\sTime/] } comment cfg.join("\n") + "\n" end @@ -72,7 +72,7 @@ class PowerConnect < Oxidized::Model end out << line.strip end - out = out.select { |line| not line[/Up\sTime/] } + out = out.reject { |line| line[/Up\sTime/] } out = comment out.join "\n" out << "\n" end diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 444fb5b..705a814 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -67,7 +67,7 @@ class Procurve < Oxidized::Model # not supported on all models cmd 'show system information' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ } + cfg = cfg.each_line.reject { |line| line.match /(.*CPU.*)|(.*Up Time.*)|(.*Total.*)|(.*Free.*)|(.*Lowest.*)|(.*Missed.*)/ } cfg = cfg.join comment cfg end diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb index 6717446..b62a3be 100644 --- a/lib/oxidized/model/routeros.rb +++ b/lib/oxidized/model/routeros.rb @@ -20,7 +20,7 @@ class RouterOS < Oxidized::Model cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours cfg.gsub! /\\\r\n\s+/, '' # strip new line cfg.gsub! /# inactive time\r\n/, '' # Remove time based system comment - cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } + cfg = cfg.split("\n").reject { |line| line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } cfg.join("\n") + "\n" end end diff --git a/lib/oxidized/model/vrp.rb b/lib/oxidized/model/vrp.rb index 98229c3..e44f69e 100644 --- a/lib/oxidized/model/vrp.rb +++ b/lib/oxidized/model/vrp.rb @@ -25,7 +25,7 @@ class VRP < Oxidized::Model end cmd 'display version' do |cfg| - cfg = cfg.each_line.select {|l| not l.match /uptime/ }.join + cfg = cfg.each_line.reject { |l| l.match /uptime/ }.join comment cfg end diff --git a/lib/oxidized/model/zhoneolt.rb b/lib/oxidized/model/zhoneolt.rb index b60edb2..c50680c 100644 --- a/lib/oxidized/model/zhoneolt.rb +++ b/lib/oxidized/model/zhoneolt.rb @@ -39,7 +39,7 @@ class ZhoneOLT < Oxidized::Model end cmd 'dump console' do |cfg| - cfg = cfg.each_line.select { |line| not line.match /To Abort the operation enter Ctrl-C/ }.join + cfg = cfg.each_line.reject { |line| line.match /To Abort the operation enter Ctrl-C/ }.join end # zhone technically supports ssh, but it locks up a ton. Especially when -- cgit v1.2.1 From 0bebd8cb9ea83b4933aca702b2734e6597271fec Mon Sep 17 00:00:00 2001 From: Andre Sencioles Date: Mon, 9 Apr 2018 09:39:56 +1200 Subject: Disable paging for "show full-configuration" on FortiOS --- lib/oxidized/model/fortios.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index 23370c4..9287dce 100644 --- a/lib/oxidized/model/fortios.rb +++ b/lib/oxidized/model/fortios.rb @@ -49,7 +49,7 @@ class FortiOS < Oxidized::Model cfg << cmd('end') if @vdom_enabled - cfg << cmd('show full-configuration') + cfg << cmd('show full-configuration | grep .') cfg.join "\n" end -- cgit v1.2.1 From 36f31e7d053365fe9f5d6b64bae4ac485677c93c Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Wed, 11 Apr 2018 21:14:56 +0200 Subject: eliminate tabs in favor of double space --- lib/oxidized/model/asyncos.rb | 88 +++++++++++++++++++++--------------------- lib/oxidized/model/ciscosma.rb | 80 +++++++++++++++++++------------------- lib/oxidized/model/cumulus.rb | 2 +- 3 files changed, 85 insertions(+), 85 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/asyncos.rb b/lib/oxidized/model/asyncos.rb index 875690b..ac19e34 100644 --- a/lib/oxidized/model/asyncos.rb +++ b/lib/oxidized/model/asyncos.rb @@ -1,49 +1,49 @@ class AsyncOS < Oxidized::Model - # ESA prompt "(mail.example.com)> " - prompt /^\r*([(][\w. ]+[)][#>]\s+)$/ - comment '! ' - - # Select passphrase display option - expect /\[\S+\]>\s/ do |data, re| - send "3\n" - data.sub re, '' - end - - # handle paging - expect /-Press Any Key For More-+.*$/ do |data, re| - send " " - data.sub re, '' - end - - cmd 'version' do |cfg| - comment cfg - end + # ESA prompt "(mail.example.com)> " + prompt /^\r*([(][\w. ]+[)][#>]\s+)$/ + comment '! ' + + # Select passphrase display option + expect /\[\S+\]>\s/ do |data, re| + send "3\n" + data.sub re, '' + end + + # handle paging + expect /-Press Any Key For More-+.*$/ do |data, re| + send " " + data.sub re, '' + end + + cmd 'version' do |cfg| + comment cfg + end - cmd 'showconfig' do |cfg| - #Delete hour and date which change each run - #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' - # Delete select passphrase display option - cfg.gsub! /Choose the passphrase option:/, '' - cfg.gsub! /1. Mask passphrases \(Files with masked passphrases cannot be loaded using/, '' - cfg.gsub! /loadconfig command\)/, '' - cfg.gsub! /2. Encrypt passphrases/, '' - cfg.gsub! /3. Plain passphrases/, '' - cfg.gsub! /^3$/, '' - #Delete space - cfg.gsub! /\n\s{25,26}/, '' - #Delete after line - cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/,"\\1" - # Add a carriage return - cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/,"\\1\n\\2\\3" - # Delete prompt - cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' - cfg + cmd 'showconfig' do |cfg| + #Delete hour and date which change each run + #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' + # Delete select passphrase display option + cfg.gsub! /Choose the passphrase option:/, '' + cfg.gsub! /1. Mask passphrases \(Files with masked passphrases cannot be loaded using/, '' + cfg.gsub! /loadconfig command\)/, '' + cfg.gsub! /2. Encrypt passphrases/, '' + cfg.gsub! /3. Plain passphrases/, '' + cfg.gsub! /^3$/, '' + #Delete space + cfg.gsub! /\n\s{25,26}/, '' + #Delete after line + cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/,"\\1" + # Add a carriage return + cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/,"\\1\n\\2\\3" + # Delete prompt + cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' + cfg - end - - cfg :ssh do - pre_logout "exit" - end - + end + + cfg :ssh do + pre_logout "exit" + end + end diff --git a/lib/oxidized/model/ciscosma.rb b/lib/oxidized/model/ciscosma.rb index a52e38a..6777ad5 100644 --- a/lib/oxidized/model/ciscosma.rb +++ b/lib/oxidized/model/ciscosma.rb @@ -1,45 +1,45 @@ class CiscoSMA < Oxidized::Model - # SMA prompt "mail.example.com> " - prompt /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/ - comment '! ' - - # Select passphrase display option - expect /using loadconfig command\. \[Y\]\>/ do |data, re| - send "y\n" - data.sub re, '' - end - - # handle paging - expect /-Press Any Key For More-+.*$/ do |data, re| - send " " - data.sub re, '' - end - - cmd 'version' do |cfg| - comment cfg - end + # SMA prompt "mail.example.com> " + prompt /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/ + comment '! ' + + # Select passphrase display option + expect /using loadconfig command\. \[Y\]\>/ do |data, re| + send "y\n" + data.sub re, '' + end + + # handle paging + expect /-Press Any Key For More-+.*$/ do |data, re| + send " " + data.sub re, '' + end + + cmd 'version' do |cfg| + comment cfg + end - cmd 'showconfig' do |cfg| - #Delete hour and date which change each run - #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' - # Delete select passphrase display option - cfg.gsub! /Do you want to mask the password\? Files with masked passwords cannot be loaded/, '' - cfg.gsub! /^\s+y/, '' - # Delete space - cfg.gsub! /\n\s{25}/, '' - # Delete after line - cfg.gsub! /([\/\-,.\w><@]+)(\s{27})/,"\\1" - # Add a carriage return - cfg.gsub! /([\/\-,.\w><@]+)(\s{6,8})([\/\-,.\w><@]+)/,"\\1\n\\2\\3" - # Delete prompt - cfg.gsub! /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/, '' - cfg + cmd 'showconfig' do |cfg| + #Delete hour and date which change each run + #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' + # Delete select passphrase display option + cfg.gsub! /Do you want to mask the password\? Files with masked passwords cannot be loaded/, '' + cfg.gsub! /^\s+y/, '' + # Delete space + cfg.gsub! /\n\s{25}/, '' + # Delete after line + cfg.gsub! /([\/\-,.\w><@]+)(\s{27})/,"\\1" + # Add a carriage return + cfg.gsub! /([\/\-,.\w><@]+)(\s{6,8})([\/\-,.\w><@]+)/,"\\1\n\\2\\3" + # Delete prompt + cfg.gsub! /^\r*([-\w. ]+\.[-\w. ]+\.[-\w. ]+[#>]\s+)$/, '' + cfg - end - - cfg :ssh do - pre_logout "exit" - end - + end + + cfg :ssh do + pre_logout "exit" + end + end diff --git a/lib/oxidized/model/cumulus.rb b/lib/oxidized/model/cumulus.rb index 20acb8a..09f3955 100644 --- a/lib/oxidized/model/cumulus.rb +++ b/lib/oxidized/model/cumulus.rb @@ -68,7 +68,7 @@ class Cumulus < Oxidized::Model cfg += add_comment 'TRAFFIC' cfg += cmd 'cat /etc/cumulus/datapath/traffic.conf' - + cfg += add_comment 'ACL' cfg += cmd 'iptables -L -n' -- cgit v1.2.1 From b29550ce0cfaf6192652747d340da2dc777ac22b Mon Sep 17 00:00:00 2001 From: Zsolt Zsiros Date: Mon, 16 Apr 2018 14:48:43 +0200 Subject: model: netgear.rb support for older models (#1268) * Added support for older models (FW 5.x.y.z like on GS110TP, GS748Tv4, etc) * Fixed prompt regex * docs/Model-Notes/Netgear created * docs/Model-Notes/Netgear fixed typos --- lib/oxidized/model/netgear.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb index 0ab1349..a32eb66 100644 --- a/lib/oxidized/model/netgear.rb +++ b/lib/oxidized/model/netgear.rb @@ -1,15 +1,16 @@ class Netgear < Oxidized::Model comment '!' - prompt /^(\([\w\-.]+\)\s[#>])$/ + prompt /^(\([\w\s\-.]+\)\s[#>])$/ cmd :secret do |cfg| cfg.gsub!(/password (\S+)/, 'password ') + cfg.gsub!(/encrypted (\S+)/, 'encrypted ') cfg end cfg :telnet do - username /^User:/ + username /^(User:|Applying Interface configuration, please wait ...)/ end cfg :telnet, :ssh do -- cgit v1.2.1 From 12c770dd3504748d3e67f99175b26d0515a3d283 Mon Sep 17 00:00:00 2001 From: Yuri Zubov Date: Thu, 19 Apr 2018 14:19:41 +0300 Subject: Basic support for NDMS OS (Zyxel Keenetic) --- lib/oxidized/model/ndms.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/oxidized/model/ndms.rb (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/ndms.rb b/lib/oxidized/model/ndms.rb new file mode 100644 index 0000000..c632bb9 --- /dev/null +++ b/lib/oxidized/model/ndms.rb @@ -0,0 +1,25 @@ +class NDMS < Oxidized::Model + + # Pull config from Zyxel Keenetic devices from version NDMS >= 2.0 + + comment '! ' + + prompt /^([\w.@()-]+[#>]\s?)/m + + cmd 'show version' do |cfg| + cfg = cfg.each_line.to_a[1..-3].join + comment cfg + end + + cmd 'show running-config' do |cfg| + cfg = cfg.each_line.to_a[1..-2] + cfg = cfg.reject { |line| line.match /(clock date|checksum)/ }.join + cfg + end + + cfg :telnet do + username /^Login:/ + password /^Password:/ + pre_logout 'exit' + end +end -- cgit v1.2.1 From 21e3d6490496573f25ef77fe8172766ac7d1a736 Mon Sep 17 00:00:00 2001 From: Wild Kat Date: Sat, 21 Apr 2018 13:27:05 +0200 Subject: the great makeover - standardize layout, alignment, indentation --- lib/oxidized/model/acos.rb | 31 +++++----- lib/oxidized/model/acsw.rb | 11 +--- lib/oxidized/model/aen.rb | 3 +- lib/oxidized/model/aireos.rb | 8 +-- lib/oxidized/model/alteonos.rb | 34 ++++++----- lib/oxidized/model/alvarion.rb | 4 -- lib/oxidized/model/aos.rb | 6 +- lib/oxidized/model/aos7.rb | 5 +- lib/oxidized/model/aosw.rb | 24 ++++---- lib/oxidized/model/apc_aos.rb | 3 - lib/oxidized/model/arbos.rb | 5 +- lib/oxidized/model/aricentiss.rb | 2 - lib/oxidized/model/asa.rb | 66 +++++++++++---------- lib/oxidized/model/asyncos.rb | 39 ++++++------- lib/oxidized/model/audiocodes.rb | 12 ++-- lib/oxidized/model/awplus.rb | 79 +++++++++++++------------ lib/oxidized/model/boss.rb | 7 +-- lib/oxidized/model/br6910.rb | 88 ++++++++++++++-------------- lib/oxidized/model/c4cmts.rb | 8 +-- lib/oxidized/model/catos.rb | 2 - lib/oxidized/model/cisconga.rb | 4 +- lib/oxidized/model/ciscosma.rb | 37 ++++++------ lib/oxidized/model/ciscosmb.rb | 8 +-- lib/oxidized/model/comware.rb | 12 ++-- lib/oxidized/model/coriant8600.rb | 8 +-- lib/oxidized/model/coriantgroove.rb | 8 +-- lib/oxidized/model/corianttmos.rb | 4 +- lib/oxidized/model/cumulus.rb | 58 +++++++++---------- lib/oxidized/model/datacom.rb | 2 - lib/oxidized/model/dcnos.rb | 2 - lib/oxidized/model/dlink.rb | 2 +- lib/oxidized/model/dnos.rb | 8 +-- lib/oxidized/model/edgecos.rb | 6 +- lib/oxidized/model/edgeos.rb | 2 - lib/oxidized/model/edgeswitch.rb | 4 +- lib/oxidized/model/enterasys.rb | 4 +- lib/oxidized/model/eos.rb | 14 ++--- lib/oxidized/model/fabricos.rb | 8 +-- lib/oxidized/model/firewareos.rb | 3 - lib/oxidized/model/fortios.rb | 28 +++++---- lib/oxidized/model/ftos.rb | 6 +- lib/oxidized/model/fujitsupy.rb | 6 +- lib/oxidized/model/gaiaos.rb | 16 ++---- lib/oxidized/model/gcombnps.rb | 19 +++--- lib/oxidized/model/hatteras.rb | 13 +++-- lib/oxidized/model/hirschmann.rb | 18 +++--- lib/oxidized/model/hpebladesystem.rb | 32 +++++------ lib/oxidized/model/hpemsa.rb | 3 - lib/oxidized/model/ios.rb | 108 +++++++++++++++++------------------ lib/oxidized/model/iosxr.rb | 4 +- lib/oxidized/model/ipos.rb | 4 +- lib/oxidized/model/ironware.rb | 27 ++++----- lib/oxidized/model/isam.rb | 9 ++- lib/oxidized/model/junos.rb | 10 ++-- lib/oxidized/model/masteros.rb | 4 +- lib/oxidized/model/mlnxos.rb | 7 +-- lib/oxidized/model/model.rb | 21 ++++--- lib/oxidized/model/mtrlrfs.rb | 5 +- lib/oxidized/model/ndms.rb | 1 - lib/oxidized/model/netgear.rb | 2 - lib/oxidized/model/netscaler.rb | 2 - lib/oxidized/model/nos.rb | 4 +- lib/oxidized/model/nxos.rb | 5 +- lib/oxidized/model/oneos.rb | 14 ++--- lib/oxidized/model/opengear.rb | 6 +- lib/oxidized/model/opnsense.rb | 8 +-- lib/oxidized/model/outputs.rb | 4 +- lib/oxidized/model/panos.rb | 3 +- lib/oxidized/model/pfsense.rb | 8 +-- lib/oxidized/model/planet.rb | 20 +++---- lib/oxidized/model/powerconnect.rb | 9 +-- lib/oxidized/model/procurve.rb | 4 +- lib/oxidized/model/quantaos.rb | 8 +-- lib/oxidized/model/routeros.rb | 4 +- lib/oxidized/model/saos.rb | 1 - lib/oxidized/model/screenos.rb | 8 +-- lib/oxidized/model/sgos.rb | 5 +- lib/oxidized/model/siklu.rb | 2 - lib/oxidized/model/slxos.rb | 26 ++++----- lib/oxidized/model/sros.rb | 1 - lib/oxidized/model/tmos.rb | 4 +- lib/oxidized/model/tplink.rb | 18 +++--- lib/oxidized/model/trango.rb | 13 ++--- lib/oxidized/model/ucs.rb | 1 - lib/oxidized/model/voltaire.rb | 9 +-- lib/oxidized/model/voss.rb | 3 +- lib/oxidized/model/vrp.rb | 7 +-- lib/oxidized/model/vyatta.rb | 4 +- lib/oxidized/model/weos.rb | 4 +- lib/oxidized/model/xos.rb | 6 +- lib/oxidized/model/zhoneolt.rb | 2 +- lib/oxidized/model/zynos.rb | 4 +- 92 files changed, 511 insertions(+), 680 deletions(-) (limited to 'lib/oxidized/model') diff --git a/lib/oxidized/model/acos.rb b/lib/oxidized/model/acos.rb index 47649a2..a2db89c 100644 --- a/lib/oxidized/model/acos.rb +++ b/lib/oxidized/model/acos.rb @@ -3,7 +3,7 @@ class ACOS < Oxidized::Model comment '! ' - ##ACOS prompt changes depending on the state of the device + # ACOS prompt changes depending on the state of the device prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/ cmd :secret do |cfg| @@ -30,19 +30,19 @@ class ACOS < Oxidized::Model end cmd 'show partition-config all' do |cfg| - cfg.gsub! /(Current configuration).*/, '\\1 ' - cfg.gsub! /(Configuration last updated at).*/, '\\1 ' - cfg.gsub! /(Configuration last saved at).*/, '\\1 ' - cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' - cfg - end + cfg.gsub! /(Current configuration).*/, '\\1 ' + cfg.gsub! /(Configuration last updated at).*/, '\\1 ' + cfg.gsub! /(Configuration last saved at).*/, '\\1 ' + cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' + cfg + end cmd 'show running-config all-partitions' do |cfg| - cfg.gsub! /(Current configuration).*/, '\\1 ' - cfg.gsub! /(Configuration last updated at).*/, '\\1 ' - cfg.gsub! /(Configuration last saved at).*/, '\\1 ' - cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' - cfg + cfg.gsub! /(Current configuration).*/, '\\1 ' + cfg.gsub! /(Configuration last updated at).*/, '\\1 ' + cfg.gsub! /(Configuration last saved at).*/, '\\1 ' + cfg.gsub! /(Configuration last synchronized at).*/, '\\1 ' + cfg end cmd 'show aflex all-partitions' do |cfg| @@ -50,7 +50,7 @@ class ACOS < Oxidized::Model end cmd 'show aflex all-partitions' do |cfg| - @partitions_aflex = cfg.lines.each_with_object({}) do |l,h| + @partitions_aflex = cfg.lines.each_with_object({}) do |l, h| h[$1] = [] if l.match /partition: (.+)/ # only consider scripts that have passed syntax check h[h.keys.last] << $1 if l.match /^([\w-]+) +Check/ @@ -66,7 +66,7 @@ class ACOS < Oxidized::Model pre do unless @partitions_aflex.empty? out = [] - @partitions_aflex.each do |partition,arules| + @partitions_aflex.each do |partition, arules| out << "! partition: #{partition}" arules.each do |name| cmd("show aflex #{name} partition #{partition}") do |cfg| @@ -85,7 +85,7 @@ class ACOS < Oxidized::Model username /login:/ password /^Password:/ end - + cfg :telnet, :ssh do # preferred way to handle additional passwords post_login do @@ -98,5 +98,4 @@ class ACOS < Oxidized::Model post_login 'terminal width 0' pre_logout "exit\nexit\nY\r\n" end - end diff --git a/lib/oxidized/model/acsw.rb b/lib/oxidized/model/acsw.rb index 1aee2b6..c0857b3 100644 --- a/lib/oxidized/model/acsw.rb +++ b/lib/oxidized/model/acsw.rb @@ -1,5 +1,4 @@ class ACSW < Oxidized::Model - prompt /([\w.@()\/\\-]+[#>]\s?)/ comment '! ' @@ -25,16 +24,13 @@ class ACSW < Oxidized::Model cfg end - cmd 'show version' do |cfg| comment cfg end - - cmd 'show inventory' do |cfg| - comment cfg - end - + cmd 'show inventory' do |cfg| + comment cfg + end cmd 'show running-config' do |cfg| cfg = cfg.each_line.to_a[3..-1] @@ -63,5 +59,4 @@ class ACSW < Oxidized::Model post_login 'terminal length 0' pre_logout 'exit' end - end diff --git a/lib/oxidized/model/aen.rb b/lib/oxidized/model/aen.rb index 6d87433..474e6d5 100644 --- a/lib/oxidized/model/aen.rb +++ b/lib/oxidized/model/aen.rb @@ -16,5 +16,4 @@ class AEN < Oxidized::Model cfg :ssh do pre_logout 'exit' end - -end \ No newline at end of file +end diff --git a/lib/oxidized/model/aireos.rb b/lib/oxidized/model/aireos.rb index ba13120..a0378c7 100644 --- a/lib/oxidized/model/aireos.rb +++ b/lib/oxidized/model/aireos.rb @@ -1,17 +1,16 @@ class Aireos < Oxidized::Model - # AireOS (at least I think that is what it's called, hard to find data) # Used in Cisco WLC 5500 - comment '# ' ## this complains too, can't find real comment char + comment '# ' # this complains too, can't find real comment char prompt /^\([^\)]+\)\s>/ cmd :all do |cfg| cfg.each_line.to_a[1..-2].join end - ##show sysinfo? - ##show switchconfig? + # show sysinfo? + # show switchconfig? cmd 'show udi' do |cfg| cfg = comment clean cfg @@ -51,5 +50,4 @@ class Aireos < Oxidized::Model out = out.join "\n" out << "\n" end - end diff --git a/lib/oxidized/model/alteonos.rb b/lib/oxidized/model/alteonos.rb index 9eacf4e..dec4faf 100644 --- a/lib/oxidized/model/alteonos.rb +++ b/lib/oxidized/model/alteonos.rb @@ -1,5 +1,4 @@ class ALTEONOS < Oxidized::Model - prompt /^\(?.+\)?\s?[#>]/ comment '! ' @@ -11,19 +10,19 @@ class ALTEONOS < Oxidized::Model cfg end - ############################################################################################## - ## Added to remove # - ## # - ##/* Configuration dump taken 14:10:20 Fri Jul 28, 2017 (DST) # - ##/* Configuration last applied at 16:17:05 Fri Jul 14, 2017 # - ##/* Configuration last save at 16:17:43 Fri Jul 14, 2017 # - ##/* Version 29.0.3.12, vXXXXXXXX, Base MAC address XXXXXXXXXXX # - ##/* To restore SSL Offloading configuration and management HTTPS access, # - ##/* it is recommended to include the private keys in the dump. # - ## OR # - ##/* To restore SSL Offloading configuration and management HTTPS access,it is recommended # - ##/* to include the private keys in the dump. # - ## # + ############################################################################################## + # Added to remove # + # # + # /* Configuration dump taken 14:10:20 Fri Jul 28, 2017 (DST) # + # /* Configuration last applied at 16:17:05 Fri Jul 14, 2017 # + # /* Configuration last save at 16:17:43 Fri Jul 14, 2017 # + # /* Version 29.0.3.12, vXXXXXXXX, Base MAC address XXXXXXXXXXX # + # /* To restore SSL Offloading configuration and management HTTPS access, # + # /* it is recommended to include the private keys in the dump. # + # OR # + # /* To restore SSL Offloading configuration and management HTTPS access,it is recommended # + # /* to include the private keys in the dump. # + # # ############################################################################################## cmd 'cfg/dump' do |cfg| @@ -35,19 +34,19 @@ class ALTEONOS < Oxidized::Model cfg end - #Answer for Dispay private keys + # Answer for Dispay private keys expect /^Display private keys\?\s?\[y\/n\]\: $/ do |data, re| send "n\r" data.sub re, '' end - #Answer for sync to peer on exit + # Answer for sync to peer on exit expect /^Confirm Sync to Peer\s?\[y\/n\]\: $/ do |data, re| send "n\r" data.sub re, '' end - #Answer for Unsaved configuration + # Answer for Unsaved configuration expect /^(WARNING: There are unsaved configuration changes).*/ do |data, re| send "n\r" data.sub re, '' @@ -56,5 +55,4 @@ class ALTEONOS < Oxidized::Model cfg :ssh do pre_logout 'exit' end - end diff --git a/lib/oxidized/model/alvarion.rb b/lib/oxidized/model/alvarion.rb index 7a4dcc7..8831f49 100644 --- a/lib/oxidized/model/alvarion.rb +++ b/lib/oxidized/model/alvarion.rb @@ -1,5 +1,4 @@ class Alvarion < Oxidized::Model - # Used in Alvarion wisp equipment # Run this command as an instance of Model so we can access node @@ -7,9 +6,6 @@ class Alvarion < Oxidized::Model cmd "#{node.auth[:password]}.cfg" end - cfg :tftp do - end - end diff --git a/lib/oxidized/model/aos.rb b/lib/oxidized/model/aos.rb index ec73b92..fed78c8 100644 --- a/lib/oxidized/model/aos.rb +++ b/lib/oxidized/model/aos.rb @@ -1,8 +1,7 @@ class AOS < Oxidized::Model - # Alcatel-Lucent Operating System # used in OmniSwitch - + comment '! ' cmd :all do |cfg| @@ -10,7 +9,7 @@ class AOS < Oxidized::Model end cmd 'show system' do |cfg| - cfg = cfg.each_line.find{|line|line.match 'Description'} + cfg = cfg.each_line.find { |line| line.match 'Description' } comment cfg.to_s.strip end @@ -34,5 +33,4 @@ class AOS < Oxidized::Model cfg :telnet, :ssh do pre_logout 'exit' end - end diff --git a/lib/oxidized/model/aos7.rb b/lib/oxidized/model/aos7.rb index 8d11066..00bee54 100644 --- a/lib/oxidized/model/aos7.rb +++ b/lib/oxidized/model/aos7.rb @@ -1,8 +1,7 @@ class AOS7 < Oxidized::Model - # Alcatel-Lucent Operating System Version 7 (Linux based) # used in OmniSwitch 6900/10k - + comment '! ' cmd :all do |cfg, cmdstring| @@ -11,7 +10,7 @@ class AOS7 < Oxidized::Model end cmd 'show system' do |cfg| - cfg = cfg.each_line.find{|line|line.match 'Description'} + cfg = cfg.each_line.find { |line| line.match 'Description' } comment cfg.to_s.strip + "\n" end diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb index 3397305..7543353 100644 --- a/lib/oxidized/model/aosw.rb +++ b/lib/oxidized/model/aosw.rb @@ -1,14 +1,13 @@ class AOSW < Oxidized::Model - # AOSW Aruba Wireless, IAP, Instant Controller and Mobility Access Switches # Used in Alcatel OAW-4750 WLAN controller # Also Dell controllers - + # HPE Aruba Switches should use a different model as the software is based on the HP Procurve line. - + # Support for IAP & Instant Controller tested with 115, 205, 215 & 325 running 6.4.4.8-4.2.4.5_57965 # Support for Mobility Access Switches tested with S2500-48P & S2500-24P running 7.4.1.4_54199 and S2500-24P running 7.4.1.7_57823 - # All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored. + # All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored. comment '# ' prompt /^\(?.+\)?\s[#>]/ @@ -26,11 +25,11 @@ class AOSW < Oxidized::Model cfg.gsub!(/ sha (\S+)/, ' sha ') cfg.gsub!(/ des (\S+)/, ' des ') cfg.gsub!(/mobility-manager (\S+) user (\S+) (\S+)/, 'mobility-manager \1 user \2 ') - cfg.gsub!(/mgmt-user (\S+) (root|guest\-provisioning|network\-operations|read\-only|location\-api\-mgmt) (\S+)$/, 'mgmt-user \1 \2 ') #MAS & Wireless Controler - cfg.gsub!(/mgmt-user (\S+) (\S+)( (read\-only|guest\-mgmt))?$/, 'mgmt-user \1 \3') #IAP -#MAS format: mgmt-user -#IAP format (root user): mgmt-user -#IAP format: mgmt-user + cfg.gsub!(/mgmt-user (\S+) (root|guest\-provisioning|network\-operations|read\-only|location\-api\-mgmt) (\S+)$/, 'mgmt-user \1 \2 ') # MAS & Wireless Controler + cfg.gsub!(/mgmt-user (\S+) (\S+)( (read\-only|guest\-mgmt))?$/, 'mgmt-user \1 \3') # IAP + # MAS format: mgmt-user + # IAP format (root user): mgmt-user + # IAP format: mgmt-user cfg.gsub!(/key (\S+)$/, 'key ') cfg.gsub!(/wpa-passphrase (\S+)$/, 'wpa-passphrase ') cfg.gsub!(/bkup-passwords (\S+)$/, 'bkup-passwords ') @@ -45,17 +44,17 @@ class AOSW < Oxidized::Model end cmd 'show inventory' do |cfg| - cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS) rstrip_cfg clean cfg end cmd 'show slots' do |cfg| - cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS) rstrip_cfg comment cfg end cmd 'show license' do |cfg| - cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ #Don't show for unsupported devices (IAP and MAS) + cfg = "" if cfg.match /(Invalid input detected at '\^' marker|Parse error)/ # Don't show for unsupported devices (IAP and MAS) rstrip_cfg comment cfg end @@ -112,5 +111,4 @@ class AOSW < Oxidized::Model out = comment out.join "\n" out << "\n" end - end diff --git a/lib/oxidized/model/apc_aos.rb b/lib/oxidized/model/apc_aos.rb index 530d436..5a4d232 100644 --- a/lib/oxidized/model/apc_aos.rb +++ b/lib/oxidized/model/apc_aos.rb @@ -1,11 +1,8 @@ class Apc_aos < Oxidized::Model - cmd 'config.ini' do |cfg| cfg.gsub! /^; Configuration file\, generated on.*/, '' end cfg :ftp do end - end - diff --git a/lib/oxidized/model/arbos.rb b/lib/oxidized/model/arbos.rb index 389f3f6..51b269d 100644 --- a/lib/oxidized/model/arbos.rb +++ b/lib/oxidized/model/arbos.rb @@ -1,9 +1,8 @@ -class ARBOS < Oxidized::Model - +class ARBOS < Oxidized::Model # Arbor OS model # prompt /^[\S\s]+\n([\w.@-]+[:\/#>]+)\s?$/ - comment '# ' + comment '# ' cmd 'system hardware' do |cfg| cfg.gsub! /^Boot\ time\:\s.+/, '' # Remove boot timer diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb index 14f8502..77b78f4 100644 --- a/lib/oxidized/model/aricentiss.rb +++ b/lib/oxidized/model/aricentiss.rb @@ -4,7 +4,6 @@ # 0 SSE-G48-TG4 (P2-01) 1.0.16-9 class AricentISS < Oxidized::Model - prompt (/^(\e\[27m)?[ \r]*[\w-]+# ?$/) cfg :ssh do @@ -49,5 +48,4 @@ class AricentISS < Oxidized::Model l }.join.gsub(/ +$/, '') end - end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index bea0705..dfd94b1 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -1,5 +1,4 @@ class ASA < Oxidized::Model - # Cisco ASA model # # Only SSH supported for the sake of security @@ -54,48 +53,47 @@ class ASA < Oxidized::Model post_login 'terminal pager 0' pre_logout 'exit' end - + def single_context - # Single context mode - cmd 'more system:running-config' do |cfg| - cfg = cfg.each_line.to_a[3..-1].join - cfg.gsub! /^: [^\n]*\n/, '' - # backup any xml referenced in the configuration. - anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten - anyconnect_profiles.each do |profile| - cfg << (comment profile + "\n" ) - cmd ("more" + profile) do |xml| - cfg << (comment xml) - end + # Single context mode + cmd 'more system:running-config' do |cfg| + cfg = cfg.each_line.to_a[3..-1].join + cfg.gsub! /^: [^\n]*\n/, '' + # backup any xml referenced in the configuration. + anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten + anyconnect_profiles.each do |profile| + cfg << (comment profile + "\n") + cmd ("more" + profile) do |xml| + cfg << (comment xml) end - # if DAP is enabled, also backup dap.xml - if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/) - cfg << (comment "disk0:/dap.xml\n") - cmd "more disk0:/dap.xml" do |xml| - cfg << (comment xml) - end + end + # if DAP is enabled, also backup dap.xml + if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/) + cfg << (comment "disk0:/dap.xml\n") + cmd "more disk0:/dap.xml" do |xml| + cfg << (comment xml) end - cfg end + cfg + end end def multiple_context - # Multiple context mode - cmd 'changeto system' do |cfg| - cmd 'show running-config' do |systemcfg| - allcfg = "\n\n" + systemcfg + "\n\n" - contexts = systemcfg.scan(/^context (\S+)$/) - files = systemcfg.scan(/config-url (\S+)$/) - contexts.each_with_index do |cont, i| - allcfg = allcfg + "\n\n----------========== [ CONTEXT " + cont.join(" ") + " FILE " + files[i].join(" ") + " ] ==========----------\n\n" - cmd "more " + files[i].join(" ") do |cfgcontext| - allcfg = allcfg + "\n\n" + cfgcontext - end + # Multiple context mode + cmd 'changeto system' do |cfg| + cmd 'show running-config' do |systemcfg| + allcfg = "\n\n" + systemcfg + "\n\n" + contexts = systemcfg.scan(/^context (\S+)$/) + files = systemcfg.scan(/config-url (\S+)$/) + contexts.each_with_index do |cont, i| + allcfg = allcfg + "\n\n----------========== [ CONTEXT " + cont.join(" ") + " FILE " + files[i].join(" ") + " ] ==========----------\n\n" + cmd "more " + files[i].join(" ") do |cfgcontext| + allcfg = allcfg + "\n\n" + cfgcontext end - cfg = allcfg end - cfg + cfg = allcfg end + cfg + end end - end diff --git a/lib/oxidized/model/asyncos.rb b/lib/oxidized/model/asyncos.rb index ac19e34..2857ef8 100644 --- a/lib/oxidized/model/asyncos.rb +++ b/lib/oxidized/model/asyncos.rb @@ -1,28 +1,27 @@ class AsyncOS < Oxidized::Model - # ESA prompt "(mail.example.com)> " prompt /^\r*([(][\w. ]+[)][#>]\s+)$/ - comment '! ' - - # Select passphrase display option - expect /\[\S+\]>\s/ do |data, re| - send "3\n" + comment '! ' + + # Select passphrase display option + expect /\[\S+\]>\s/ do |data, re| + send "3\n" data.sub re, '' end - + # handle paging - expect /-Press Any Key For More-+.*$/ do |data, re| + expect /-Press Any Key For More-+.*$/ do |data, re| send " " data.sub re, '' end - + cmd 'version' do |cfg| comment cfg end cmd 'showconfig' do |cfg| - #Delete hour and date which change each run - #cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' + # Delete hour and date which change each run + # cfg.gsub! /\sCurrent Time: \S+\s\S+\s+\S+\s\S+\s\S+/, ' Current Time:' # Delete select passphrase display option cfg.gsub! /Choose the passphrase option:/, '' cfg.gsub! /1. Mask passphrases \(Files with masked passphrases cannot be loaded using/, '' @@ -30,20 +29,18 @@ class AsyncOS < Oxidized::Model cfg.gsub! /2. Encrypt passphrases/, '' cfg.gsub! /3. Plain passphrases/, '' cfg.gsub! /^3$/, '' - #Delete space - cfg.gsub! /\n\s{25,26}/, '' - #Delete after line - cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/,"\\1" - # Add a carriage return - cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/,"\\1\n\\2\\3" + # Delete space + cfg.gsub! /\n\s{25,26}/, '' + # Delete after line + cfg.gsub! /([-\\\/,.\w><@]+)(\s{25,27})/, "\\1" + # Add a carriage return + cfg.gsub! /([-\\\/,.\w><@]+)(\s{6})([-\\\/,.\w><@]+)/, "\\1\n\\2\\3" # Delete prompt - cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' + cfg.gsub! /^\r*([(][\w. ]+[)][#>]\s+)$/, '' cfg - end - + cfg :ssh do pre_logout "exit" end - end diff --git a/lib/oxidized/model/audiocodes.rb b/lib/oxidized/model/audiocodes.rb index b7ee70e..2c77abb 100644 --- a/lib/oxidized/model/audiocodes.rb +++ b/lib/oxidized/model/audiocodes.rb @@ -1,20 +1,17 @@ class AudioCodes < Oxidized::Model - -# Pull config from AudioCodes Mediant devices from version > 7.0 + # Pull config from AudioCodes Mediant devices from version > 7.0 prompt /^\r?([\w.@() -]+[#>]\s?)$/ - comment '## ' + comment '## ' expect /\s*--MORE--$/ do |data, re| - send ' ' data.sub re, '' - end cmd 'show running-config' do |cfg| - cfg + cfg end cfg :ssh do @@ -22,11 +19,10 @@ class AudioCodes < Oxidized::Model password /^.+password:\s$/ pre_logout 'exit' end - + cfg :telnet do username /^Username:\s$/ password /^Password:\s$/ pre_logout 'exit' end - end diff --git a/lib/oxidized/model/awplus.rb b/lib/oxidized/model/awplus.rb index 1d8fbcd..7c88d60 100644 --- a/lib/oxidized/model/awplus.rb +++ b/lib/oxidized/model/awplus.rb @@ -1,27 +1,26 @@ class AWPlus < Oxidized::Model + # Allied Telesis Alliedware Plus Model# + # https://www.alliedtelesis.com/products/software/AlliedWare-Plus - #Allied Telesis Alliedware Plus Model# - #https://www.alliedtelesis.com/products/software/AlliedWare-Plus - prompt /^(\r?[\w.@:\/-]+[#>]\s?)$/ - comment '! ' + comment '! ' - #Avoids needing "term length 0" to display full config file. - expect /--More--/ do |data, re| - send ' ' - data.sub re, '' - end + # Avoids needing "term length 0" to display full config file. + expect /--More--/ do |data, re| + send ' ' + data.sub re, '' + end - #Removes gibberish pager output e.g. VT100 escape codes + # Removes gibberish pager output e.g. VT100 escape codes cmd :all do |cfg| cfg.gsub! /\e\[K/, '' # example how to handle pager - cleareol EL0 cfg.gsub! /\e\[7m\e\[m/, '' # example how to handle pager - Reverse SGR7 - cfg.gsub! /\r/, '' # Filters rogue ^M - see issue #415 + cfg.gsub! /\r/, '' # Filters rogue ^M - see issue #415 cfg.each_line.to_a[1..-2].join end - #Remove passwords from config file. - #Add vars "remove_secret: true" to global oxidized config file to enable. + # Remove passwords from config file. + # Add vars "remove_secret: true" to global oxidized config file to enable. cmd :secret do |cfg| cfg.gsub! /^(snmp-server community).*/, '\\1 ' @@ -34,52 +33,52 @@ class AWPlus < Oxidized::Model cfg end - #Adds "Show system" output to start of config. + # Adds "Show system" output to start of config. cmd 'Show System' do |cfg| - comment cfg.insert(0,"--------------------------------------------------------------------------------! \n") - #Unhash below to write a comment in the config file. - cfg.insert(0,"Starting: Show system cmd \n") + comment cfg.insert(0, "--------------------------------------------------------------------------------! \n") + # Unhash below to write a comment in the config file. + cfg.insert(0, "Starting: Show system cmd \n") cfg << "\n \nEnding: show system cmd" comment cfg << "\n--------------------------------------------------------------------------------! \n \n" - #Removes the following lines from "show system" in output file. This ensures oxidized diffs are meaningful. - comment cfg.each_line.reject { |line| - line.match /^$\n/ or #Remove blank lines in "sh sys" - line.match /System Status\s*.*/ or - line.match /RAM\s*:.*/ or - line.match /Uptime\s*:.*/ or - line.match /Flash\s*:.*/ or - line.match /Current software\s*:.*/ or - line.match /Software version\s*:.*/ or - line.match /Build date\s*:.*/ }.join + # Removes the following lines from "show system" in output file. This ensures oxidized diffs are meaningful. + comment cfg.each_line.reject { |line| + line.match /^$\n/ or # Remove blank lines in "sh sys" + line.match /System Status\s*.*/ or + line.match /RAM\s*:.*/ or + line.match /Uptime\s*:.*/ or + line.match /Flash\s*:.*/ or + line.match /Current software\s*:.*/ or + line.match /Software version\s*:.*/ or + line.match /Build date\s*:.*/ + } .join end - - #Actually get the devices running config# + + # Actually get the devices running config# cmd 'show running-config' do |cfg| cfg end - - #Config required for telnet to detect username prompt + + # Config required for telnet to detect username prompt cfg :telnet do username /login:\s/ - end + end - #Main login config - cfg :telnet, :ssh do + # Main login config + cfg :telnet, :ssh do post_login do if vars :enable send "enable\n" expect /^Password:\s/ cmd vars(:enable) + "\r\n" else - cmd 'enable' # Required for Priv-Exec users without enable PW to be put into "enable mode". + cmd 'enable' # Required for Priv-Exec users without enable PW to be put into "enable mode". end -# cmd 'terminal length 0' #set so the entire config is output without intervention. + # cmd 'terminal length 0' #set so the entire config is output without intervention. end pre_logout do -# cmd 'terminal no length' #Sets term length back to default on exit. - send "exit\r\n" + # cmd 'terminal no length' #Sets term length back to default on exit. + send "exit\r\n" end - end - + end end diff --git a/lib/oxidized/model/boss.rb b/lib/oxidized/model/boss.rb index 02201a1..cf762ee 100644 --- a/lib/oxidized/model/boss.rb +++ b/lib/oxidized/model/boss.rb @@ -16,7 +16,7 @@ class Boss < Oxidized::Model data.sub re, '' end - # Handle the Failed retries since last login + # Handle the Failed retries since last login # no known way to disable other than to implement radius authentication expect /Press ENTER to continue/ do |data, re| send "\n" @@ -29,7 +29,7 @@ class Boss < Oxidized::Model send "c" data.sub re, '' end - + # needed for proper formatting cmd('') { |cfg| comment "#{cfg}\n" } @@ -43,7 +43,7 @@ class Boss < Oxidized::Model cfg.gsub! /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} .*/, '' comment "#{cfg}\n" end - + # if a stack then collect the stacking information cmd 'show stack-info' do |cfg| if @stack @@ -72,5 +72,4 @@ class Boss < Oxidized::Model post_login 'terminal length 0' post_login 'terminal width 132' end - end diff --git a/lib/oxidized/model/br6910.rb b/lib/oxidized/model/br6910.rb index df93793..1e79da3 100644 --- a/lib/oxidized/model/br6910.rb +++ b/lib/oxidized/model/br6910.rb @@ -1,45 +1,43 @@ - -class BR6910 < Oxidized::Model - - prompt /^([\w.@()-]+[#>]\s?)$/ - comment '! ' - - # not possible to disable paging prior to show running-config - expect /^((.*)Others to exit ---(.*))$/ do |data, re| - send 'a' - data.sub re, '' - end - - cmd :all do |cfg| - # sometimes br6910s inserts arbitrary whitespace after commands are - # issued on the CLI, from run to run. this normalises the output. - cfg.each_line.to_a[1..-2].drop_while { |e| e.match /^\s+$/ }.join - end - - cmd 'show version' do |cfg| - comment cfg - end - - # show flash is not possible on a brocade 6910, do dir instead - # to see flash contents (includes config file names) - cmd 'dir' do |cfg| - comment cfg - end - - cmd 'show running-config' do |cfg| - arr = cfg.each_line.to_a - arr[2..-1].join unless arr.length < 2 - end - - cfg :telnet do - username /^Username:/ - password /^Password:/ - end - - # post login and post logout - cfg :telnet, :ssh do - post_login '' - pre_logout 'exit' - end - -end + +class BR6910 < Oxidized::Model + prompt /^([\w.@()-]+[#>]\s?)$/ + comment '! ' + + # not possible to disable paging prior to show running-config + expect /^((.*)Others to exit ---(.*))$/ do |data, re| + send 'a' + data.sub re, '' + end + + cmd :all do |cfg| + # sometimes br6910s inserts arbitrary whitespace after commands are + # issued on the CLI, from run to run. this normalises the output. + cfg.each_line.to_a[1..-2].drop_while { |e| e.match /^\s+$/ }.join + end + + cmd 'show version' do |cfg| + comment cfg + end + + # show flash is not possible on a brocade 6910, do dir instead + # to see flash contents (includes config file names) + cmd 'dir' do |cfg| + comment cfg + end + + cmd 'show running-config' do |cfg| + arr = cfg.each_line.to_a + arr[2..-1].join unless arr.length < 2 + end + + cfg :telnet do + username /^Username:/ + password /^Password:/ + end + + # post login and post logout + cfg :telnet, :ssh do + post_login '' + pre_logout 'exit' + end +end diff --git a/lib/oxidized/model/c4cmts.rb b/lib/oxidized/model/c4cmts.rb index 150029c..8ea27c6 100644 --- a/lib/oxidized/model/c4cmts.rb +++ b/lib/oxidized/model/c4cmts.rb @@ -1,15 +1,14 @@ class C4CMTS < Oxidized::Model - # Arris C4 CMTS prompt /^([\w.@:\/-]+[#>]\s?)$/ comment '! ' cmd :all do |cfg| - cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n" + cfg.each_line.to_a[1..-2].map { |line| line.delete("\r").rstrip }.join("\n") + "\n" end - cmd :secret do |cfg| + cmd :secret do |cfg| cfg.gsub! /(.+)\s+encrypted-password\s+\w+\s+(.*)/, '\\1