summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/aosw.rb13
-rw-r--r--lib/oxidized/model/asa.rb8
-rw-r--r--lib/oxidized/model/c4cmts.rb52
-rw-r--r--lib/oxidized/model/comware.rb5
-rw-r--r--lib/oxidized/model/dnos.rb47
-rw-r--r--lib/oxidized/model/edgeos.rb27
-rw-r--r--lib/oxidized/model/ironware.rb49
-rw-r--r--lib/oxidized/model/junos.rb2
-rw-r--r--lib/oxidized/model/masteros.rb46
-rw-r--r--lib/oxidized/model/powerconnect.rb2
-rw-r--r--lib/oxidized/model/routeros.rb8
-rw-r--r--lib/oxidized/model/xos.rb5
-rw-r--r--lib/oxidized/model/zynos.rb12
13 files changed, 250 insertions, 26 deletions
diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb
index 203c5e0..43e1cff 100644
--- a/lib/oxidized/model/aosw.rb
+++ b/lib/oxidized/model/aosw.rb
@@ -5,7 +5,7 @@ class AOSW < Oxidized::Model
# Also Dell controllers
comment '# '
- prompt /^\([^)]+\) #/
+ prompt /^\([^)]+\) [#>]/
cmd :all do |cfg|
cfg.each_line.to_a[1..-2].join
@@ -36,7 +36,16 @@ class AOSW < Oxidized::Model
end
cfg :telnet, :ssh do
+ if vars :enable
+ post_login do
+ send 'enable\n'
+ send vars(:enable) + '\n'
+ end
+ end
post_login 'no paging'
+ if vars :enable
+ pre_logout 'exit'
+ end
pre_logout 'exit'
end
@@ -50,7 +59,7 @@ class AOSW < Oxidized::Model
next if line.match /[0-9]+ (RPM|mV|C)$/
out << line.strip
end
- out = out.join "\n"
+ out = comment out.join "\n"
out << "\n"
end
diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb
index d257e9e..547afd7 100644
--- a/lib/oxidized/model/asa.rb
+++ b/lib/oxidized/model/asa.rb
@@ -23,16 +23,16 @@ class ASA < Oxidized::Model
comment cfg
end
+ cmd 'show inventory' do |cfg|
+ comment cfg
+ end
+
cmd 'more system:running-config' do |cfg|
cfg = cfg.each_line.to_a[3..-1].join
cfg.gsub! /^: [^\n]*\n/, ''
cfg
end
- cmd 'show inventory' do |cfg|
- comment cfg
- end
-
cfg :ssh do
if vars :enable
post_login do
diff --git a/lib/oxidized/model/c4cmts.rb b/lib/oxidized/model/c4cmts.rb
new file mode 100644
index 0000000..150029c
--- /dev/null
+++ b/lib/oxidized/model/c4cmts.rb
@@ -0,0 +1,52 @@
+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"
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /(.+)\s+encrypted-password\s+\w+\s+(.*)/, '\\1 <secret hidden> \\2'
+ cfg.gsub! /(snmp-server community)\s+".*"\s+(.*)/, '\\1 <secret hidden> \\2'
+ cfg.gsub! /(tacacs.*\s+key)\s+".*"\s+(.*)/, '\\1 <secret hidden> \\2'
+ cfg.gsub! /(cable authstring)\s+\w+\s+(.*)/, '\\1 <secret hidden> \\2'
+ cfg
+ end
+
+ cmd 'show environment' do |cfg|
+ cfg.gsub! /\s+[\-\d]+\s+C\s+[\(\s\d]+\s+\F\)/, '' # remove temperature readings
+ cfg.each_line.to_a[1..-2].join
+ comment cfg
+ end
+
+ cmd 'show version' do |cfg|
+ # remove uptime readings at char 55 and beyond
+ cfg = cfg.each_line.map{|line|line.rstrip.slice(0..54)}.join("\n") + "\n"
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg = cfg.each_line.to_a[1..-2].join
+ cfg
+ end
+
+ cfg :telnet do
+ username /^Username:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ if vars :enable
+ post_login do
+ send "enable\n"
+ send vars(:enable) + "\n"
+ end
+ end
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/comware.rb b/lib/oxidized/model/comware.rb
index bfc1524..9b36e8b 100644
--- a/lib/oxidized/model/comware.rb
+++ b/lib/oxidized/model/comware.rb
@@ -1,7 +1,8 @@
class Comware < Oxidized::Model
# HP (A-series)/H3C/3Com Comware
- prompt /^(<[\w.-]+>)$/
+ # sometimes the prompt might have a leading nul
+ prompt /^\0*(<[\w.-]+>)$/
comment '# '
# example how to handle pager
@@ -38,7 +39,7 @@ class Comware < Oxidized::Model
end
cmd 'display version' do |cfg|
- cfg = cfg.each_line.select {|l| not l.match /uptime/ }.join
+ cfg = cfg.each_line.select {|l| not l.match /uptime/i }.join
comment cfg
end
diff --git a/lib/oxidized/model/dnos.rb b/lib/oxidized/model/dnos.rb
new file mode 100644
index 0000000..1c31aad
--- /dev/null
+++ b/lib/oxidized/model/dnos.rb
@@ -0,0 +1,47 @@
+class DNOS < Oxidized::Model
+
+ # Force10 DNOS model #
+
+ comment '! '
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[2..-2].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /secret (\d+) (\S+).*/, '<secret hidden>'
+ cfg
+ end
+
+ cmd 'show inventory' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show inventory media' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg = cfg.each_line.to_a[3..-1].join
+ cfg
+ end
+
+ cfg :telnet do
+ username /^Login:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'terminal length 0'
+ post_login 'terminal width 0'
+ if vars :enable
+ post_login do
+ send "enable\n"
+ send vars(:enable) + "\n"
+ end
+ end
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/edgeos.rb b/lib/oxidized/model/edgeos.rb
new file mode 100644
index 0000000..2a8d663
--- /dev/null
+++ b/lib/oxidized/model/edgeos.rb
@@ -0,0 +1,27 @@
+class Edgeos < Oxidized::Model
+
+ # EdgeOS #
+
+ prompt /\@.*?\:~\$\s/
+
+ cmd :all do |cfg|
+ cfg = cfg.lines.to_a[1..-2].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /community (\S+) {/, 'community <hidden> {'
+ cfg
+ end
+
+ cmd 'show configuration | no-more'
+
+ cfg :telnet do
+ username /login:\s/
+ password /^Password:\s/
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb
index e18902b..87a51a6 100644
--- a/lib/oxidized/model/ironware.rb
+++ b/lib/oxidized/model/ironware.rb
@@ -1,6 +1,6 @@
class IronWare < Oxidized::Model
- prompt /^.+[>#]\s?$/
+ prompt /^.*(telnet|ssh)\@.+[>#]\s?$/i
comment '! '
#to handle pager without enable
@@ -16,22 +16,34 @@ class IronWare < Oxidized::Model
#end
cmd :all do |cfg|
- cfg.each_line.to_a[1..-2].join
- end
-
- cmd 'show running-config' do |cfg|
- cfg = cfg.each_line.to_a[3..-1].join
- cfg
+ # sometimes ironware 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|
- cfg.gsub! /(^((.*)system uptime(.*))$)/, '' #remove unwanted line system uptime
+ cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' #remove unwanted line system uptime
+ cfg.gsub! /[Uu]p\s?[Tt]ime is .*/,''
+
comment cfg
end
cmd 'show chassis' do |cfg|
- cfg.gsub! "\xFF", '' # ugly hack - avoids JSON.dump utf-8 breakage on 1.9..
+ cfg.encode!("UTF-8", :invalid => :replace) #sometimes ironware returns broken encoding
cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature
+ cfg.gsub! /Speed = [A-Z]{3} \(\d{2}\%\)/, '' #remove unwanted lines Speed Fans
+ cfg.gsub! /current speed is [A-Z]{3} \(\d{2}\%\)/, ''
+ cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C'
+ if cfg.include? "TEMPERATURE"
+ sc = StringScanner.new cfg
+ out = ''
+ temps = ''
+ out << sc.scan_until(/.*TEMPERATURE/)
+ temps << sc.scan_until(/.*Fans/)
+ out << sc.rest
+ cfg = out
+ end
+
comment cfg
end
@@ -40,22 +52,31 @@ class IronWare < Oxidized::Model
end
cmd 'show module' do |cfg|
+ cfg.gsub! /^((Invalid input)|(Type \?)).*$/, '' # some ironware devices are fixed config
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:/
+ # match expected prompts on both older and newer
+ # versions of IronWare
+ username /^(Please Enter Login Name|Username):/
+ password /^(Please Enter )Password:/
end
#handle pager with enable
cfg :telnet, :ssh do
if vars :enable
post_login do
- send "enable\n"
- send vars(:enable) + "\n"
+ send "enable\r\n"
+ send vars(:enable) + "\r\n"
end
end
+ post_login ''
post_login 'skip-page-display'
post_login 'terminal length 0'
pre_logout 'logout'
@@ -63,4 +84,4 @@ class IronWare < Oxidized::Model
pre_logout 'exit'
end
-end \ No newline at end of file
+end
diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb
index e43d71a..0e921d2 100644
--- a/lib/oxidized/model/junos.rb
+++ b/lib/oxidized/model/junos.rb
@@ -9,7 +9,7 @@ class JunOS < Oxidized::Model
cmd :all do |cfg|
# we don't need screen-scraping in ssh due to exec
cfg = cfg.lines.to_a[1..-2].join if telnet
- cfg.lines.map { |line| line.rstrip }.join "\n"
+ cfg.lines.map { |line| line.rstrip }.join("\n") + "\n"
end
cmd :secret do |cfg|
diff --git a/lib/oxidized/model/masteros.rb b/lib/oxidized/model/masteros.rb
new file mode 100644
index 0000000..3f5a2fc
--- /dev/null
+++ b/lib/oxidized/model/masteros.rb
@@ -0,0 +1,46 @@
+class MasterOS < Oxidized::Model
+
+ # MRV MasterOS model #
+
+comment '!'
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /username (\S+) password encrypted (\S+) class (\S+).*/, '<secret hidden>'
+ cfg
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd 'show inventory' do |cfg|
+ cfg = cfg.each_line.to_a[0..-2].join
+ comment cfg
+ end
+
+ cmd 'show plugins' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show hw-config' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg = cfg.each_line.to_a[3..-1].join
+ cfg
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'no pager'
+ if vars :enable
+ post_login do
+ send "enable\n"
+ send vars(:enable) + "\n"
+ end
+ end
+ pre_logout 'exit'
+ end
+
+end \ No newline at end of file
diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb
index 0b28f37..ec15402 100644
--- a/lib/oxidized/model/powerconnect.rb
+++ b/lib/oxidized/model/powerconnect.rb
@@ -25,7 +25,7 @@ class PowerConnect < Oxidized::Model
cmd 'show running-config'
- cfg :telnet do
+ cfg :telnet, :ssh do
username /^User( Name)?:/
password /^\r?Password:/
end
diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb
index bd588b7..4822500 100644
--- a/lib/oxidized/model/routeros.rb
+++ b/lib/oxidized/model/routeros.rb
@@ -1,5 +1,5 @@
class RouterOS < Oxidized::Model
- prompt /^\[\w+@\S+\]\s?>\s?$/
+ prompt /\[\w+@\S+\]\s?>\s?$/
comment "# "
cmd '/system routerboard print' do |cfg|
@@ -7,10 +7,16 @@ class RouterOS < Oxidized::Model
end
cmd '/export' do |cfg|
+ cfg.gsub! /\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]/, '' # strip ANSI colours
cfg = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
cfg.join("\n") + "\n"
end
+ cfg :telnet do
+ username /^Login:/
+ password /^Password:/
+ end
+
cfg :ssh do
exec true
end
diff --git a/lib/oxidized/model/xos.rb b/lib/oxidized/model/xos.rb
index 88c81ed..de8ec39 100644
--- a/lib/oxidized/model/xos.rb
+++ b/lib/oxidized/model/xos.rb
@@ -6,7 +6,9 @@ class XOS < Oxidized::Model
comment '# '
cmd :all do |cfg|
- cfg.each_line.to_a[1..-2].join.rstrip
+ # xos inserts leading \r characters and other trailing white space.
+ # this deletes extraneous \r and trailing white space.
+ cfg.each_line.to_a[1..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
end
cmd 'show version' do |cfg|
@@ -35,6 +37,7 @@ class XOS < Oxidized::Model
cfg :telnet, :ssh do
post_login 'disable clipaging'
pre_logout 'exit'
+ pre_logout 'n'
end
end
diff --git a/lib/oxidized/model/zynos.rb b/lib/oxidized/model/zynos.rb
new file mode 100644
index 0000000..89be8af
--- /dev/null
+++ b/lib/oxidized/model/zynos.rb
@@ -0,0 +1,12 @@
+class ZyNOS < Oxidized::Model
+
+ # Used in Zyxel DSLAMs, such as SAM1316
+
+ comment '! '
+
+ cmd 'config-0'
+
+ cfg :ftp do
+ end
+
+end