summaryrefslogtreecommitdiff
path: root/lib/oxidized/model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/model')
-rw-r--r--lib/oxidized/model/acos.rb16
-rw-r--r--lib/oxidized/model/alvarion.rb13
-rw-r--r--lib/oxidized/model/aosw.rb23
-rw-r--r--lib/oxidized/model/apc_aos.rb11
-rw-r--r--lib/oxidized/model/asa.rb2
-rw-r--r--lib/oxidized/model/casa.rb46
-rw-r--r--lib/oxidized/model/catos.rb11
-rw-r--r--lib/oxidized/model/ciscosmb.rb9
-rw-r--r--lib/oxidized/model/dlink.rb36
-rw-r--r--lib/oxidized/model/dnos.rb7
-rw-r--r--lib/oxidized/model/eos.rb2
-rw-r--r--lib/oxidized/model/fiberdriver.rb21
-rw-r--r--lib/oxidized/model/fujitsupy.rb42
-rw-r--r--lib/oxidized/model/hatteras.rb52
-rw-r--r--lib/oxidized/model/hpebladesystem.rb83
-rw-r--r--lib/oxidized/model/ios.rb2
-rw-r--r--lib/oxidized/model/ironware.rb12
-rw-r--r--lib/oxidized/model/pfsense.rb16
-rw-r--r--lib/oxidized/model/planet.rb83
-rw-r--r--lib/oxidized/model/powerconnect.rb2
-rw-r--r--lib/oxidized/model/procurve.rb4
-rw-r--r--lib/oxidized/model/routeros.rb3
-rw-r--r--lib/oxidized/model/trango.rb62
23 files changed, 521 insertions, 37 deletions
diff --git a/lib/oxidized/model/acos.rb b/lib/oxidized/model/acos.rb
index bb9846e..47649a2 100644
--- a/lib/oxidized/model/acos.rb
+++ b/lib/oxidized/model/acos.rb
@@ -6,6 +6,13 @@ class ACOS < Oxidized::Model
##ACOS prompt changes depending on the state of the device
prompt /^([-\w.\/:?\[\]\(\)]+[#>]\s?)$/
+ cmd :secret do |cfg|
+ cfg.gsub!(/community read encrypted (\S+)/, 'community read encrypted <hidden>') # snmp
+ cfg.gsub!(/secret encrypted (\S+)/, 'secret encrypted <hidden>') # tacacs-server
+ cfg.gsub!(/password encrypted (\S+)/, 'password encrypted <hidden>') # user
+ cfg
+ end
+
cmd 'show version' do |cfg|
cfg.gsub! /\s(Last configuration saved at).*/, ' \\1 <removed>'
cfg.gsub! /\s(Memory).*/, ' \\1 <removed>'
@@ -22,11 +29,20 @@ class ACOS < Oxidized::Model
comment cfg
end
+ cmd 'show partition-config all' do |cfg|
+ cfg.gsub! /(Current configuration).*/, '\\1 <removed>'
+ cfg.gsub! /(Configuration last updated at).*/, '\\1 <removed>'
+ cfg.gsub! /(Configuration last saved at).*/, '\\1 <removed>'
+ cfg.gsub! /(Configuration last synchronized at).*/, '\\1 <removed>'
+ cfg
+ end
+
cmd 'show running-config all-partitions' do |cfg|
cfg.gsub! /(Current configuration).*/, '\\1 <removed>'
cfg.gsub! /(Configuration last updated at).*/, '\\1 <removed>'
cfg.gsub! /(Configuration last saved at).*/, '\\1 <removed>'
cfg.gsub! /(Configuration last synchronized at).*/, '\\1 <removed>'
+ cfg
end
cmd 'show aflex all-partitions' do |cfg|
diff --git a/lib/oxidized/model/alvarion.rb b/lib/oxidized/model/alvarion.rb
new file mode 100644
index 0000000..3c762de
--- /dev/null
+++ b/lib/oxidized/model/alvarion.rb
@@ -0,0 +1,13 @@
+class Alvarion < Oxidized::Model
+
+ # Used in Alvarion wisp equipment
+
+ # Run this command as an instance of Model so we can access node
+ pre do
+ cmd "#{node.auth[:password]}.cfg"
+ end
+
+
+ cfg :tftp {}
+
+end
diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb
index 394561f..11d8442 100644
--- a/lib/oxidized/model/aosw.rb
+++ b/lib/oxidized/model/aosw.rb
@@ -28,19 +28,21 @@ class AOSW < Oxidized::Model
cmd 'show version' do |cfg|
cfg = cfg.each_line.select { |line| not line.match /Switch uptime/i }
- comment cfg.join
+ rstrip_cfg comment cfg.join
end
cmd 'show inventory' do |cfg|
- clean cfg
+ rstrip_cfg clean cfg
end
cmd 'show slots' do |cfg|
- comment cfg
+ rstrip_cfg comment cfg
end
+
cmd 'show license' do |cfg|
- comment cfg
+ rstrip_cfg comment cfg
end
+
cmd 'show running-config' do |cfg|
out = []
cfg.each_line do |line|
@@ -60,8 +62,8 @@ class AOSW < Oxidized::Model
cfg :telnet, :ssh do
if vars :enable
post_login do
- send 'enable\n'
- send vars(:enable) + '\n'
+ send "enable\n"
+ cmd vars(:enable)
end
end
post_login 'no paging'
@@ -72,6 +74,15 @@ class AOSW < Oxidized::Model
pre_logout 'exit'
end
+ def rstrip_cfg cfg
+ out = []
+ cfg.each_line do |line|
+ out << line.rstrip
+ end
+ out = out.join "\n"
+ out << "\n"
+ end
+
def clean cfg
out = []
cfg.each_line do |line|
diff --git a/lib/oxidized/model/apc_aos.rb b/lib/oxidized/model/apc_aos.rb
new file mode 100644
index 0000000..530d436
--- /dev/null
+++ b/lib/oxidized/model/apc_aos.rb
@@ -0,0 +1,11 @@
+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/asa.rb b/lib/oxidized/model/asa.rb
index a41348e..df30059 100644
--- a/lib/oxidized/model/asa.rb
+++ b/lib/oxidized/model/asa.rb
@@ -15,7 +15,7 @@ class ASA < Oxidized::Model
cfg.gsub! /username (\S+) password (\S+) (.*)/, 'username \1 password <secret hidden> \3'
cfg.gsub! /ikev2 pre-shared-key (\S+)/, 'ikev2 pre-shared-key <secret hidden>'
cfg.gsub! /ikev2 (remote|local)-authentication pre-shared-key (\S+)/, 'ikev2 \1-authentication pre-shared-key <secret hidden>'
- cfg.gsub! /^(aaa-server TACACS\+ \(\S+\) host.*\n\skey) \S+$/m, '\1 <secret hidden>'
+ cfg.gsub! /^(aaa-server TACACS\+? \(\S+\) host.*\n\skey) \S+$/mi, '\1 <secret hidden>'
cfg
end
diff --git a/lib/oxidized/model/casa.rb b/lib/oxidized/model/casa.rb
new file mode 100644
index 0000000..e85c904
--- /dev/null
+++ b/lib/oxidized/model/casa.rb
@@ -0,0 +1,46 @@
+class Casa < Oxidized::Model
+ # Casa Systems CMTS
+
+ prompt /^([\w.@()-]+[#>]\s?)$/
+ comment '! '
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp community) \S+/, '\\1 <configuration removed>'
+ cfg.gsub! /^(snmp comm-tbl) \S+ \S+/, '\\1 <removed> <removed>'
+ cfg.gsub! /^(console-password encrypted) \S+/, '\\1 <secret hidden>'
+ cfg.gsub! /^(password encrypted) \S+/, '\\1 <secret hidden>'
+ cfg.gsub! /^(tacacs-server key) \S+/, '\\1 <secret hidden>'
+ cfg
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd 'show system' do |cfg|
+ comment cfg.each_line.reject { |line| line.match /^\s+System (Time|Uptime): / }.join
+ end
+
+ cmd 'show version' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show run'
+
+ cfg :telnet do
+ username /^Username:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'page-off'
+ # preferred way to handle additional passwords
+ if vars :enable
+ post_login do
+ send "enable\n"
+ cmd vars(:enable)
+ end
+ end
+ pre_logout 'logout'
+ end
+end
diff --git a/lib/oxidized/model/catos.rb b/lib/oxidized/model/catos.rb
index 874ebbc..bac9eec 100644
--- a/lib/oxidized/model/catos.rb
+++ b/lib/oxidized/model/catos.rb
@@ -1,6 +1,6 @@
class Catos < Oxidized::Model
- prompt /^[\w.@-]+> \(enable\) $/
+ prompt /^[\w.@-]+>\s?(\(enable\) )?$/
comment '# '
cmd :all do |cfg|
@@ -28,8 +28,15 @@ class Catos < Oxidized::Model
password /^Password:/
end
- cfg :ssh, :telnet do
+ cfg :telnet, :ssh do
post_login 'set length 0'
+ # preferred way to handle additional passwords
+ if vars :enable
+ post_login do
+ send "enable\n"
+ cmd vars(:enable)
+ end
+ end
pre_logout 'exit'
end
diff --git a/lib/oxidized/model/ciscosmb.rb b/lib/oxidized/model/ciscosmb.rb
index 3ef9a85..e5501d5 100644
--- a/lib/oxidized/model/ciscosmb.rb
+++ b/lib/oxidized/model/ciscosmb.rb
@@ -33,14 +33,13 @@ class CiscoSMB < Oxidized::Model
cfg
end
- cfg :telnet do
- username /^User Name:/
- password /^\r?Password:$/
- end
-
cfg :telnet, :ssh do
+ username /^User ?[nN]ame:/
+ password /^\r?Password:$/
post_login 'terminal datadump' # Disable pager
post_login 'terminal width 0'
+ post_login 'terminal len 0'
+ pre_logout 'exit' #exit returns to previous priv level, no way to quit from exec(#)
pre_logout 'exit'
end
diff --git a/lib/oxidized/model/dlink.rb b/lib/oxidized/model/dlink.rb
new file mode 100644
index 0000000..5756bad
--- /dev/null
+++ b/lib/oxidized/model/dlink.rb
@@ -0,0 +1,36 @@
+class Dlink < Oxidized::Model
+ # D-LINK Switches
+
+ prompt /^(\r*[\w.@():-]+[#>]\s?)$/
+ comment '# '
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(create snmp community) \S+/, '\\1 <removed>'
+ cfg.gsub! /^(create snmp group) \S+/, '\\1 <removed>'
+ cfg
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[2..-2].map{|line|line.delete("\r").rstrip}.join("\n") + "\n"
+ end
+
+ cmd 'show switch' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show vlan' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show config current'
+
+ cfg :telnet do
+ username /\r*username:/
+ password /\r*password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'disable clipaging'
+ pre_logout 'logout'
+ end
+end
diff --git a/lib/oxidized/model/dnos.rb b/lib/oxidized/model/dnos.rb
index 1c31aad..a44630e 100644
--- a/lib/oxidized/model/dnos.rb
+++ b/lib/oxidized/model/dnos.rb
@@ -33,15 +33,16 @@ class DNOS < Oxidized::Model
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"
+ cmd vars(:enable)
end
end
+ post_login 'terminal length 0'
+ post_login 'terminal width 0'
pre_logout 'exit'
+ pre_logout 'exit'
end
end
diff --git a/lib/oxidized/model/eos.rb b/lib/oxidized/model/eos.rb
index 75da0fa..a9f3ff3 100644
--- a/lib/oxidized/model/eos.rb
+++ b/lib/oxidized/model/eos.rb
@@ -22,7 +22,7 @@ class EOS < Oxidized::Model
comment cfg
end
- cmd 'show running-config | no-more' do |cfg|
+ cmd 'show running-config | no-more | exclude ! Time:' do |cfg|
cfg
end
diff --git a/lib/oxidized/model/fiberdriver.rb b/lib/oxidized/model/fiberdriver.rb
new file mode 100644
index 0000000..8f8eb07
--- /dev/null
+++ b/lib/oxidized/model/fiberdriver.rb
@@ -0,0 +1,21 @@
+class FiberDriver < Oxidized::Model
+ prompt /\w+#/
+ comment "! "
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+ cmd 'show inventory' do |cfg|
+ comment cfg
+ end
+
+ cmd "show running-config" do |cfg|
+ cfg.each_line.to_a[3..-1].join
+ end
+
+ cfg :ssh do
+ post_login 'terminal length 0'
+ post_login 'terminal width 512'
+ pre_logout 'exit'
+ end
+end
diff --git a/lib/oxidized/model/fujitsupy.rb b/lib/oxidized/model/fujitsupy.rb
new file mode 100644
index 0000000..20a78dd
--- /dev/null
+++ b/lib/oxidized/model/fujitsupy.rb
@@ -0,0 +1,42 @@
+class FujitsuPY < Oxidized::Model
+
+ prompt /^(\([\w.-]*\)\s#|^\S+\#\s)$/
+ comment '! '
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+# 1Gbe switch
+ cmd 'show version' do |cfg|
+ cfg.gsub! /^(<ERROR> : 2 : format error)$/, ''
+ comment cfg
+ end
+
+# 10Gbe switch
+ cmd 'show system information' do |cfg|
+ cfg.gsub! /^Current-time : [\w\s:]*$/, ''
+ cfg.gsub! /^(\s{33}\^)$/, ''
+ cfg.gsub! /^(\% Invalid input detected at '\^' marker.)$/, ''
+ comment cfg
+ end
+
+ cmd 'show running-config' do |cfg|
+ cfg
+ end
+
+ cfg :telnet do
+ username /^Username:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'no pager'
+ post_login 'terminal pager disable'
+ pre_logout do
+ send "quit\n"
+ send "n\n"
+ end
+ end
+
+end
diff --git a/lib/oxidized/model/hatteras.rb b/lib/oxidized/model/hatteras.rb
new file mode 100644
index 0000000..4192cbc
--- /dev/null
+++ b/lib/oxidized/model/hatteras.rb
@@ -0,0 +1,52 @@
+class Hatteras < Oxidized::Model
+ # Hatteras Networks
+
+ prompt /^(\r?[\w.@()-]+[#>]\s?)$/
+ comment '# '
+
+ expect /WARNING: System configuration changes will be lost when the device restarts./ do |data, re|
+ send "y\r"
+ data.sub re, ''
+ end
+
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(community) \S+/, '\\1 "<configuration removed>"'
+ cfg.gsub! /^(communityString) "\S+"/, '\\1 "<configuration removed>"'
+ cfg.gsub! /^(key) "\S+"/, '\\1 "<secret hidden>"'
+ cfg
+ end
+
+ cmd :all do |cfg|
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd "show switch\r" do |cfg|
+ cfg = cfg.each_line.reject { |line| line.match /Switch uptime|Switch temperature|Last reset reason/ or
+ line.match /TermCpuUtil|^\s+\^$|ERROR: Bad command/ }.join
+ comment cfg
+ end
+
+ cmd "show card\r" do |cfg|
+ cfg = cfg.each_line.reject { |line| line.match /Card uptime|Card temperature|Last reset reason/ or
+ line.match /TermCpuUtil|^\s+\^$|ERROR: Bad command/ }.join
+ comment cfg
+ end
+
+ cmd "show sfp *\r" do |cfg|
+ comment cfg
+ end
+
+ cmd "show config run\r" do |cfg|
+ cfg
+ end
+
+ cfg :telnet do
+ username /^Login:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout "logout\r"
+ end
+end
diff --git a/lib/oxidized/model/hpebladesystem.rb b/lib/oxidized/model/hpebladesystem.rb
new file mode 100644
index 0000000..5e34de8
--- /dev/null
+++ b/lib/oxidized/model/hpebladesystem.rb
@@ -0,0 +1,83 @@
+class HPEBladeSystem < Oxidized::Model
+ # HPE Onboard Administrator
+
+ prompt /.*> /
+ comment '# '
+
+ expect /^\s*--More--\s+.*$/ do |data, re|
+ send ' '
+ data.sub re, ''
+ end
+
+ cmd :all do |cfg|
+ cfg = cfg.delete("\r").each_line.to_a[0..-1].map{|line|line.rstrip}.join("\n") + "\n"
+ cfg.each_line.to_a[0..-2].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(SET SNMP COMMUNITY (READ|WRITE)).*/, '\\1 <configuration removed>'
+ cfg
+ end
+
+ cmd 'show oa info' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show oa network' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show oa certificate' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show sshfingerprint' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show fru' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show network' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show vlan' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show rack name' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show server list' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show server names' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show server port map all' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show server info all' do |cfg|
+ comment cfg
+ end
+
+ cmd 'show config' do |cfg|
+ cfg.gsub! /^#(Generated on:) .*$/, '\\1 <removed>'
+ cfg.gsub /^\s+/, ''
+ end
+
+ cfg :telnet do
+ username /\slogin:/
+ password /^Password: /
+ end
+
+ cfg :telnet, :ssh do
+ pre_logout "exit"
+ end
+end
diff --git a/lib/oxidized/model/ios.rb b/lib/oxidized/model/ios.rb
index 1f099c8..3cbe0f0 100644
--- a/lib/oxidized/model/ios.rb
+++ b/lib/oxidized/model/ios.rb
@@ -26,7 +26,9 @@ class IOS < Oxidized::Model
cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
cfg.gsub! /^username \S+ password \d \S+/, '<secret hidden>'
+ cfg.gsub! /^username \S+ secret \d \S+/, '<secret hidden>'
cfg.gsub! /^enable password \d \S+/, '<secret hidden>'
+ cfg.gsub! /^enable secret \d \S+/, '<secret hidden>'
cfg.gsub! /wpa-psk ascii \d \S+/, '<secret hidden>'
cfg.gsub! /^tacacs-server key \d \S+/, '<secret hidden>'
cfg
diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb
index 1e8c30e..db341d1 100644
--- a/lib/oxidized/model/ironware.rb
+++ b/lib/oxidized/model/ironware.rb
@@ -2,14 +2,14 @@ class IronWare < Oxidized::Model
prompt /^.*(telnet|ssh)\@.+[>#]\s?$/i
comment '! '
-
+
#to handle pager without enable
#expect /^((.*)--More--(.*))$/ do |data, re|
# send ' '
# data.sub re, ''
#end
-
+
#to remove backspace (if handle pager without enable)
#expect /^((.*)[\b](.*))$/ do |data, re|
# data.sub re, ''
@@ -44,14 +44,14 @@ class IronWare < Oxidized::Model
out << sc.rest
cfg = out
end
-
+
comment cfg
end
-
+
cmd 'show flash' do |cfg|
comment cfg
end
-
+
cmd 'show module' do |cfg|
cfg.gsub! /^((Invalid input)|(Type \?)).*$/, '' # some ironware devices are fixed config
comment cfg
@@ -74,7 +74,7 @@ class IronWare < Oxidized::Model
if vars :enable
post_login do
send "enable\r\n"
- send vars(:enable) + "\r\n"
+ cmd vars(:enable)
end
end
post_login ''
diff --git a/lib/oxidized/model/pfsense.rb b/lib/oxidized/model/pfsense.rb
index cd6885c..c02c0d0 100644
--- a/lib/oxidized/model/pfsense.rb
+++ b/lib/oxidized/model/pfsense.rb
@@ -1,20 +1,14 @@
class PfSense < Oxidized::Model
-
- comment '# '
-
- #add a comment in the final conf
- def add_comment comment
- "\n###### #{comment} ######\n"
- end
+ # use other use than 'admin' user, 'admin' user cannot get ssh/exec. See issue #535
+
cmd :all do |cfg|
cfg.each_line.to_a[1..-2].join
end
- #show the persistent configuration
- pre do
- cfg = add_comment 'Configuration'
- cfg += cmd 'cat /cf/conf/config.xml'
+ cmd 'cat /cf/conf/config.xml' do |cfg|
+ cfg.gsub! /\s<revision>\s*.*\s*<time>\d*<\/time>\s*.*\s*<\/revision>/, ''
+ cfg
end
cfg :ssh do
diff --git a/lib/oxidized/model/planet.rb b/lib/oxidized/model/planet.rb
new file mode 100644
index 0000000..05a369a
--- /dev/null
+++ b/lib/oxidized/model/planet.rb
@@ -0,0 +1,83 @@
+class Planet < Oxidized::Model
+
+ prompt /^\r?([\w.@()-]+[#>]\s?)$/
+ comment '! '
+
+ # example how to handle pager
+ #expect /^\s--More--\s+.*$/ do |data, re|
+ # send ' '
+ # data.sub re, ''
+ #end
+
+ # non-preferred way to handle additional PW prompt
+ #expect /^[\w.]+>$/ do |data|
+ # send "enable\n"
+ # send vars(:enable) + "\n"
+ # data
+ #end
+
+ cmd :all do |cfg|
+ #cfg.gsub! /\cH+\s{8}/, '' # example how to handle pager
+ #cfg.gsub! /\cH+/, '' # example how to handle pager
+ cfg.each_line.to_a[1..-2].join
+ end
+
+ cmd :secret do |cfg|
+ cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'
+ cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'
+ cfg.gsub! /^username \S+ password \d \S+/, '<secret hidden>'
+ cfg.gsub! /^enable password \d \S+/, '<secret hidden>'
+ cfg.gsub! /wpa-psk ascii \d \S+/, '<secret hidden>'
+ cfg.gsub! /^tacacs-server key \d \S+/, '<secret hidden>'
+ cfg
+ end
+
+ cmd 'show version' do |cfg|
+ cfg.gsub! "\n\r", "\n"
+ @planetgs = true if cfg.match /^System Name\w*:\w*GS-.*$/
+ @planetsgs = true if cfg.match /SGS-(.*) Device, Compiled on .*$/
+
+ cfg = cfg.each_line.to_a[0...-2]
+
+ # Strip system time and system uptime from planet gs switches
+ cfg = cfg.reject { |line| line.match /System Time\s*:.*/ }
+ cfg = cfg.reject { |line| line.match /System Uptime\s*:.*/ }
+
+ comment cfg.join
+ end
+
+
+ cmd 'show running-config' do |cfg|
+ cfg.gsub! "\n\r", "\n"
+ cfg = cfg.each_line.to_a
+
+ cfg = cfg.reject { |line| line.match "Building configuration..." }
+
+ if @planetsgs
+ cfg << cmd('show transceiver detail | include transceiver detail information|found|Type|length|Nominal|wavelength|Base information') do |cfg|
+ comment cfg
+ end
+ end
+
+ cfg.join
+ end
+
+
+ cfg :telnet do
+ username /^Username:/
+ password /^Password:/
+ end
+
+ cfg :telnet, :ssh do
+ post_login 'terminal length 0'
+ # preferred way to handle additional passwords
+ if vars :enable
+ post_login do
+ send "enable\n"
+ cmd vars(:enable)
+ end
+ end
+ pre_logout 'exit'
+ end
+
+end
diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb
index f0fa3df..ac36c26 100644
--- a/lib/oxidized/model/powerconnect.rb
+++ b/lib/oxidized/model/powerconnect.rb
@@ -39,7 +39,7 @@ class PowerConnect < Oxidized::Model
if vars :enable
post_login do
send "enable\n"
- send vars(:enable) + "\n"
+ cmd vars(:enable)
end
end
diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb
index da792e6..c117df3 100644
--- a/lib/oxidized/model/procurve.rb
+++ b/lib/oxidized/model/procurve.rb
@@ -57,4 +57,8 @@ class Procurve < Oxidized::Model
pre_logout "logout\ny\nn"
end
+ cfg :ssh do
+ pty_options({ chars_wide: 1000 })
+ end
+
end
diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb
index 4822500..a92ad5e 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+)*\]\s?>\s?$/
comment "# "
cmd '/system routerboard print' do |cfg|
@@ -8,6 +8,7 @@ class RouterOS < Oxidized::Model
cmd '/export' do |cfg|
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 = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] }
cfg.join("\n") + "\n"
end
diff --git a/lib/oxidized/model/trango.rb b/lib/oxidized/model/trango.rb
new file mode 100644
index 0000000..b2aa1e7
--- /dev/null
+++ b/lib/oxidized/model/trango.rb
@@ -0,0 +1,62 @@
+class Trango < Oxidized::Model
+ # take a Trangolink sysinfo output and turn it into a configuration file
+
+ prompt /^#>\s?/
+ comment '# '
+
+ cmd 'sysinfo' do |cfg|
+ out = []
+ comments = []
+ cfg.each_line do |line|
+ if line.match /\[Opmode\] (off|on) \[Default Opmode\] (off|on)/
+ out << "opmode " + Regexp.last_match[1]
+ out << "defaultopmode " + Regexp.last_match[2]
+ end
+ if line.match /\[Tx Power\] ([\-\d]+) dBm/
+ out << "power " + Regexp.last_match[1]
+ end
+ if line.match /\[Active Channel\] (\d+) (v|h)/
+ out << "freq " + Regexp.last_match[1] + ' ' + Regexp.last_match[2]
+ end
+ if line.match /\[Peer ID\] ([A-F0-9]+)/
+ out << "peerid " + Regexp.last_match[1]
+ end
+ if line.match /\[Unit Type\] (\S+)/
+ out << "utype " + Regexp.last_match[1]
+ end
+ if line.match /\[(Hardware Version|Firmware Version|Model|S\/N)\] (\S+)/
+ comments << '# ' + Regexp.last_match[1] + ': ' + Regexp.last_match[2]
+ end
+ if line.match /\[Remarks\] (\S+)/
+ out << "remarks " + Regexp.last_match[1]
+ end
+ if line.match /\[RSSI LED\] (on|off)/
+ out << "rssiled " + Regexp.last_match[1]
+ end
+ if line.match /\[Speed\] (\d+) Mbps/
+ speed = Regexp.last_match[1]
+ end
+ if line.match /\[Tx MIR\] (\d+) Kbps/
+ out << "mir ".concat(Regexp.last_match[1])
+ end
+ if line.match /\[Auto Rate Shift\] (on|off)/
+ out << "autorateshift ".concat(Regexp.last_match[1])
+ if Regexp.last_match[1].eql? 'off'
+ out << "speed $speed"
+ end
+ end
+ if line.match /\[IP\] (\S+) \[Subnet Mask\] (\S+) \[Gateway\] (\S+)/
+ out << "ipconfig " + Regexp.last_match[1] + ' ' +
+ Regexp.last_match[2] + ' ' +
+ Regexp.last_match[3]
+ end
+ end
+ comments.push(*out).join "\n"
+ end
+
+ cfg :telnet do
+ password /Password:/
+ pre_logout 'exit'
+ end
+
+end