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/edgeos.rb27
-rw-r--r--lib/oxidized/model/ironware.rb7
-rw-r--r--lib/oxidized/model/masteros.rb46
-rw-r--r--lib/oxidized/model/routeros.rb8
-rw-r--r--lib/oxidized/model/xos.rb2
-rw-r--r--lib/oxidized/model/zynos.rb12
7 files changed, 108 insertions, 7 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/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 1ec8b80..805e07b 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
@@ -26,13 +26,13 @@ class IronWare < Oxidized::Model
cmd 'show version' do |cfg|
cfg.gsub! /(^((.*)[Ss]ystem uptime(.*))$)/, '' #remove unwanted line system uptime
- cfg.gsub! /uptime is .*/,''
+ 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}\%\)/, ''
@@ -71,6 +71,7 @@ class IronWare < Oxidized::Model
send vars(:enable) + "\n"
end
end
+ post_login ''
post_login 'skip-page-display'
post_login 'terminal length 0'
pre_logout 'logout'
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/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..309340f 100644
--- a/lib/oxidized/model/xos.rb
+++ b/lib/oxidized/model/xos.rb
@@ -6,7 +6,7 @@ class XOS < Oxidized::Model
comment '# '
cmd :all do |cfg|
- cfg.each_line.to_a[1..-2].join.rstrip
+ cfg.each_line.to_a[1..-2].join
end
cmd 'show version' do |cfg|
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