diff options
| author | Wild Kat <wk@futureinquestion.net> | 2018-03-20 23:15:34 +0100 | 
|---|---|---|
| committer | Wild Kat <wk@futureinquestion.net> | 2018-03-20 23:15:34 +0100 | 
| commit | 6f672654c7e725bc828b6577297b86d501780c50 (patch) | |
| tree | cf29588894d0c071f0e6b393671c84b7dd605163 /lib/oxidized | |
| parent | baee367bfec7ec5241ad7e893de7df8ea7eec1e7 (diff) | |
| parent | e7075d18e055613cb0324f0fc8eecfe7adeeac56 (diff) | |
refactor snr support into dcnos model
Diffstat (limited to 'lib/oxidized')
25 files changed, 430 insertions, 188 deletions
| diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb index 23af9c2..47544fb 100644 --- a/lib/oxidized/config.rb +++ b/lib/oxidized/config.rb @@ -37,6 +37,7 @@ module Oxidized        asetus.default.input.default    = 'ssh, telnet'        asetus.default.input.debug      = false # or String for session log file        asetus.default.input.ssh.secure = false # complain about changed certs +      asetus.default.input.ftp.passive= true  # ftp passive mode        asetus.default.output.default = 'file'  # file, git        asetus.default.source.default = 'csv'   # csv, sql diff --git a/lib/oxidized/hook/githubrepo.rb b/lib/oxidized/hook/githubrepo.rb index d33e54e..f74b22a 100644 --- a/lib/oxidized/hook/githubrepo.rb +++ b/lib/oxidized/hook/githubrepo.rb @@ -51,7 +51,7 @@ class GithubRepo < Oxidized::Hook      else        if cfg.has_key?('publickey') && cfg.has_key?('privatekey')          log "Using ssh auth with key", :debug -        Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey)) +        Rugged::Credentials::SshKey.new(username: 'git', publickey: File.expand_path(cfg.publickey), privatekey: File.expand_path(cfg.privatekey), passphrase: ENV["OXIDIZED_SSH_PASSPHRASE"])        else          log "Using ssh auth with agentforwarding", :debug          Rugged::Credentials::SshKeyFromAgent.new(username: 'git') diff --git a/lib/oxidized/hook/slackdiff.rb b/lib/oxidized/hook/slackdiff.rb index 728e5a7..7cd4465 100644 --- a/lib/oxidized/hook/slackdiff.rb +++ b/lib/oxidized/hook/slackdiff.rb @@ -30,14 +30,16 @@ class SlackDiff < Oxidized::Hook          if diffenable == true            gitoutput = ctx.node.output.new            diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil -          title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" -          log "Posting diff as snippet to #{cfg.channel}" -          client.files_upload(channels: cfg.channel, as_user: true, -                              content: diff[:patch].lines.to_a[4..-1].join, -                              filetype: "diff", -                              title: title, -                              filename: "change" -                             ) +          unless diff == "no diffs" +            title = "#{ctx.node.name.to_s} #{ctx.node.group.to_s} #{ctx.node.model.class.name.to_s.downcase}" +            log "Posting diff as snippet to #{cfg.channel}" +            client.files_upload(channels: cfg.channel, as_user: true, +                                content: diff[:patch].lines.to_a[4..-1].join, +                                filetype: "diff", +                                title: title, +                                filename: "change" +                               ) +          end          end          # message custom formatted - optional          if cfg.has_key?('message') == true diff --git a/lib/oxidized/input/ftp.rb b/lib/oxidized/input/ftp.rb index 80de257..cdf3688 100644 --- a/lib/oxidized/input/ftp.rb +++ b/lib/oxidized/input/ftp.rb @@ -19,7 +19,9 @@ module Oxidized        @node       = node        @node.model.cfg['ftp'].each { |cb| instance_exec(&cb) }        @log = File.open(Oxidized::Config::Log + "/#{@node.ip}-ftp", 'w') if Oxidized.config.input.debug? -      @ftp = Net::FTP.new @node.ip, @node.auth[:username], @node.auth[:password] +      @ftp = Net::FTP.new(@node.ip) +      @ftp.passive = Oxidized.config.input.ftp.passive +      @ftp.login  @node.auth[:username], @node.auth[:password]        connected?      end diff --git a/lib/oxidized/model/aosw.rb b/lib/oxidized/model/aosw.rb index a85ead7..71fde2e 100644 --- a/lib/oxidized/model/aosw.rb +++ b/lib/oxidized/model/aosw.rb @@ -11,7 +11,7 @@ class AOSW < Oxidized::Model    # All IAPs connected to a Instant Controller will have the same config output. Only the controller needs to be monitored.     comment  '# ' -  prompt /^\(?.+\)?\s?[#>]/ +  prompt /^\(?.+\)?\s[#>]/    cmd :all do |cfg|      cfg.each_line.to_a[1..-2].join diff --git a/lib/oxidized/model/arbos.rb b/lib/oxidized/model/arbos.rb new file mode 100644 index 0000000..389f3f6 --- /dev/null +++ b/lib/oxidized/model/arbos.rb @@ -0,0 +1,27 @@ +class ARBOS  < Oxidized::Model + +  # Arbor OS model # + +  prompt /^[\S\s]+\n([\w.@-]+[:\/#>]+)\s?$/ +  comment  '# ' + +  cmd 'system hardware' do |cfg| +    cfg.gsub! /^Boot\ time\:\s.+/, '' # Remove boot timer +    cfg.gsub! /^Load\ averages\:\s.+/, '' # Remove CPU load info +    cfg = cfg.each_line.to_a[2..-1].join +    comment cfg +  end + +  cmd 'system version' do |cfg| +    comment cfg +  end + +  cmd 'config show' do |cfg| +    cfg +  end + +  cfg :ssh do +    exec true +    pre_logout 'exit' +  end +end diff --git a/lib/oxidized/model/aricentiss.rb b/lib/oxidized/model/aricentiss.rb new file mode 100644 index 0000000..8821801 --- /dev/null +++ b/lib/oxidized/model/aricentiss.rb @@ -0,0 +1,53 @@ +# Developed against: +# #show version +# Switch ID       Hardware Version                Firmware Version +# 0               SSE-G48-TG4   (P2-01)           1.0.16-9 + +class AricentISS < Oxidized::Model + +  prompt (/^(\e\[27m)?[ \r]*\w+# ?$/) + +  cfg :ssh do +    # "pagination" was misspelled in some (earlier) versions (at least 1.0.16-9) +    # 1.0.18-15 is known to include the corrected spelling +    post_login 'no cli pagination' +    post_login 'no cli pagignation' +    pre_logout 'exit' +  end + +  cmd :all do |cfg| +    # * Drop first line that contains the command, and the last line that +    #   contains a prompt +    # * Strip carriage returns +    cfg.delete("\r").each_line.to_a[1..-2].join +  end + +  cmd :secret do |cfg| +    cfg.gsub(/^(snmp community) .*/, '\1 <hidden>') +  end + +  cmd 'show system information' do |cfg| +    cfg.sub! /^Device Up Time.*\n/, '' +    cfg.delete! "\r" +    comment(cfg).gsub(/ +$/, '') +  end + +  cmd 'show running-config' do |cfg| +    comment_next = 0 +    cfg.each_line.map { |l| +      next '' if l.match /^Building configuration/ + +      if l.match /^Switch ID.*Hardware Version.*Firmware Version/ then +        comment_next = 2 +      end + +      if comment_next > 0 then +        comment_next -= 1 +        next comment(l) +      end + +      l +    }.join.gsub(/ +$/, '') +  end +   +end diff --git a/lib/oxidized/model/awplus.rb b/lib/oxidized/model/awplus.rb new file mode 100644 index 0000000..1d8fbcd --- /dev/null +++ b/lib/oxidized/model/awplus.rb @@ -0,0 +1,85 @@ +class AWPlus < Oxidized::Model + +  #Allied Telesis Alliedware Plus Model# +  #https://www.alliedtelesis.com/products/software/AlliedWare-Plus +   +  prompt /^(\r?[\w.@:\/-]+[#>]\s?)$/ +  comment  '! ' + +  #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 +  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.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.  + +  cmd :secret do |cfg| +    cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>' +    cfg.gsub! /^(username \S+ privilege \d+) (\S+).*/, '\\1 <secret hidden>' +    cfg.gsub! /^(username \S+ password \d) (\S+)/, '\\1 <secret hidden>' +    cfg.gsub! /^(username \S+ secret \d) (\S+)/, '\\1 <secret hidden>' +    cfg.gsub! /^(enable (password|secret) \d) (\S+)/, '\\1 <secret hidden>' +    cfg.gsub! /^(\s+(?:password|secret)) (?:\d )?\S+/, '\\1 <secret hidden>' +    cfg.gsub! /^(tacacs-server key \d) (\S+)/, '\\1 <secret hidden>' +    cfg +  end + +  #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") +    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 +  end +      +  #Actually get the devices running config# +  cmd 'show running-config' do |cfg| +    cfg +  end +   +  #Config required for telnet to detect username prompt +  cfg :telnet do +    username /login:\s/ +    end + +  #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".  +      end +#      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" +    end +  end   + +end diff --git a/lib/oxidized/model/br6910.rb b/lib/oxidized/model/br6910.rb index b5c9bcf..df93793 100644 --- a/lib/oxidized/model/br6910.rb +++ b/lib/oxidized/model/br6910.rb @@ -1,7 +1,7 @@  class BR6910 < Oxidized::Model
 -  prompt /^Vty-[0-9]\#$/
 +  prompt /^([\w.@()-]+[#>]\s?)$/
    comment  '! '
    # not possible to disable paging prior to show running-config
 diff --git a/lib/oxidized/model/ciscosmb.rb b/lib/oxidized/model/ciscosmb.rb index 9453059..deb4768 100644 --- a/lib/oxidized/model/ciscosmb.rb +++ b/lib/oxidized/model/ciscosmb.rb @@ -17,6 +17,7 @@ class CiscoSMB < Oxidized::Model      cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'      cfg.gsub! /username (\S+) privilege (\d+) (\S+).*/, '<secret hidden>'      cfg.gsub! /^(encrypted radius-server key).*/, '\\1 <configuration removed>' +    cfg.gsub! /System Up Time.*/, ''      cfg    end @@ -24,6 +25,10 @@ class CiscoSMB < Oxidized::Model      comment cfg    end +  cmd 'show system' do |cfg| +    comment cfg +  end +      cmd 'show bootvar' do |cfg|      comment cfg    end diff --git a/lib/oxidized/model/dcnos.rb b/lib/oxidized/model/dcnos.rb new file mode 100644 index 0000000..5a39e2b --- /dev/null +++ b/lib/oxidized/model/dcnos.rb @@ -0,0 +1,35 @@ +# DCNOS is a ZebOS derivative by DCN (http://www.dcnglobal.com/) +# In addition to products by DCN (now Yunke China), this OS type +# powers a number of re-branded OEM devices. + +# Developed against SNR S2950-24G 7.0.3.5 + +class DCNOS < Oxidized::Model + +  comment '!' + +  cmd 'show version' do |cfg| +    comment cfg +  end + +  cmd 'show running-config' do |cfg| +    cfg = cfg.each_line.to_a[1..-1] +  end + +  cfg :telnet do +    username /^login:/i +    password /^password:/i +  end + +  cfg :telnet, :ssh do +    if vars :enable +      post_login do +        send "enable\n" +        cmd vars(:enable) +      end +    end +    post_login 'terminal length 0' +    pre_logout 'exit' +  end + +end diff --git a/lib/oxidized/model/dnos.rb b/lib/oxidized/model/dnos.rb index a44630e..5c3cd53 100644 --- a/lib/oxidized/model/dnos.rb +++ b/lib/oxidized/model/dnos.rb @@ -5,6 +5,7 @@ class DNOS  < Oxidized::Model    comment  '! '    cmd :all do |cfg| +    cfg.gsub! /^% Invalid input detected at '\^' marker\.$|^\s+\^$/, ''      cfg.each_line.to_a[2..-2].join    end @@ -22,6 +23,14 @@ class DNOS  < Oxidized::Model      comment cfg    end +  cmd 'show version' do |cfg| +    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 diff --git a/lib/oxidized/model/edgecos.rb b/lib/oxidized/model/edgecos.rb new file mode 100644 index 0000000..bc205f5 --- /dev/null +++ b/lib/oxidized/model/edgecos.rb @@ -0,0 +1,47 @@ +class EdgeCOS < Oxidized::Model +   +  comment  '! ' + +  cmd :secret do |cfg| +    cfg.gsub!(/password \d+ (\S+).*/, '<secret removed>') +    cfg.gsub!(/community (\S+)/, 'community <hidden>') +    cfg +  end + +  cmd :all do |cfg| +     cfg.each_line.to_a[2..-2].join +  end + +  cmd 'show running-config' + +  cmd 'show access-list tcam-utilization' do |cfg| +    comment cfg +  end + +  cmd 'show memory' do |cfg| +    comment cfg +  end + +  cmd 'show system' do |cfg| +    comment cfg +  end + +  cmd 'show version' do |cfg| +    comment cfg +  end + +  cmd 'show watchdog' do |cfg| +    comment cfg +  end + +  cfg :telnet do +    username /^Username:/ +    password /^Password:/ +  end + +  cfg :telnet, :ssh do +    post_login 'terminal length 0' +    pre_logout 'exit' +  end + +end diff --git a/lib/oxidized/model/edgeos.rb b/lib/oxidized/model/edgeos.rb index 2a8d663..aa7a197 100644 --- a/lib/oxidized/model/edgeos.rb +++ b/lib/oxidized/model/edgeos.rb @@ -9,11 +9,15 @@ class Edgeos < Oxidized::Model    end    cmd :secret do |cfg| +    cfg.gsub! /encrypted-password (\S+).*/, 'encrypted-password <secret removed>' +    cfg.gsub! /plaintext-password (\S+).*/, 'plaintext-password <secret removed>' +    cfg.gsub! /password (\S+).*/, 'password <secret removed>' +    cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret <secret removed>'      cfg.gsub! /community (\S+) {/, 'community <hidden> {'      cfg    end -  cmd 'show configuration | no-more' +  cmd 'show configuration commands | no-more'    cfg :telnet do      username  /login:\s/ diff --git a/lib/oxidized/model/firewareos.rb b/lib/oxidized/model/firewareos.rb index f456c60..1b3d07c 100644 --- a/lib/oxidized/model/firewareos.rb +++ b/lib/oxidized/model/firewareos.rb @@ -1,6 +1,6 @@  class FirewareOS < Oxidized::Model -  prompt /^([\w.@-]+[#>]\s?)$/ +  prompt /^\[?\w*\]?\w*?(<\w*>)?(#|>)\s*$/    comment  '-- '    cmd :all do |cfg| diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index bffaf3c..23370c4 100644 --- a/lib/oxidized/model/fortios.rb +++ b/lib/oxidized/model/fortios.rb @@ -15,7 +15,7 @@ class FortiOS < Oxidized::Model    end    cmd :secret do |cfg| -    cfg.gsub! /(set (?:passwd|password|psksecret|secret|key|group-password|secondary-secret|tertiary-secret|auth-password-l1|auth-password-l2|rsso|history0|history1|inter-controller-key ENC)).*/, '\\1 <configuration removed>' +    cfg.gsub! /(set (?:passwd|password|psksecret|secret|key|group-password|secondary-secret|tertiary-secret|auth-password-l1|auth-password-l2|rsso|history0|history1|inter-controller-key ENC|passphrase ENC|login-passwd ENC)).*/, '\\1 <configuration removed>'      cfg.gsub! /(set private-key).*-+END ENCRYPTED PRIVATE KEY-*"$/m , '\\1 <configuration removed>'      cfg.gsub! /(set ca ).*-+END CERTIFICATE-*"$/m , '\\1 <configuration removed>'      cfg.gsub! /(set csr ).*-+END CERTIFICATE REQUEST-*"$/m , '\\1 <configuration removed>' @@ -63,4 +63,3 @@ cfg << cmd('end') if @vdom_enabled    end  end - diff --git a/lib/oxidized/model/junos.rb b/lib/oxidized/model/junos.rb index 2f59414..2ea0179 100644 --- a/lib/oxidized/model/junos.rb +++ b/lib/oxidized/model/junos.rb @@ -13,7 +13,10 @@ class JunOS < Oxidized::Model    end    cmd :secret do |cfg| -    cfg.gsub!(/encrypted-password (\S+).*/, '<secret removed>') +    cfg.gsub!(/encrypted-password (\S+).*/, 'encrypted-password <secret removed>') +    cfg.gsub!(/pre-shared-key ascii-text (\S+).*/, 'pre-shared-key ascii-text <secret removed>') +    cfg.gsub!(/pre-shared-key hexadecimal (\S+).*/, 'pre-shared-key hexadecimal <secret removed>') +    cfg.gsub!(/authentication-key (\S+).*/, 'authentication-key <secret removed>')      cfg.gsub!(/community (\S+) {/, 'community <hidden> {')      cfg    end diff --git a/lib/oxidized/model/powerconnect.rb b/lib/oxidized/model/powerconnect.rb index 61e1cf2..f602a36 100644 --- a/lib/oxidized/model/powerconnect.rb +++ b/lib/oxidized/model/powerconnect.rb @@ -14,7 +14,7 @@ class PowerConnect < Oxidized::Model    end    cmd :secret do |cfg| -    cfg.gsub! /^username (\S+) password \S+ (.*)/, 'username \1 password <hidden> \2' +    cfg.gsub! /^(username \S+ password (?:encrypted )?)\S+(.*)/, '\1<hidden>\2'      cfg    end diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 11d7ea9..444fb5b 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -47,6 +47,10 @@ class Procurve < Oxidized::Model      comment cfg    end +  cmd 'show system power-supply' do |cfg| +    comment cfg +  end +    cmd 'show interfaces transceiver' do |cfg|      comment cfg    end diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb index f391fb9..6717446 100644 --- a/lib/oxidized/model/routeros.rb +++ b/lib/oxidized/model/routeros.rb @@ -19,6 +19,7 @@ class RouterOS < Oxidized::Model      cmd run_cmd 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.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.join("\n") + "\n"      end diff --git a/lib/oxidized/model/snr.rb b/lib/oxidized/model/snr.rb deleted file mode 100644 index 3f1fab5..0000000 --- a/lib/oxidized/model/snr.rb +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/lib/oxidized/model/sros.rb b/lib/oxidized/model/sros.rb new file mode 100644 index 0000000..289bed3 --- /dev/null +++ b/lib/oxidized/model/sros.rb @@ -0,0 +1,118 @@ +class SROS < Oxidized::Model + +  # +  # Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent). +  # Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP. +  # + +  comment  '# ' + +  prompt /^([-\w\.:>\*]+\s?[#>]\s?)$/ + +  cmd :all do |cfg, cmdstring| +    new_cfg = comment "COMMAND: #{cmdstring}\n" +    new_cfg << cfg.each_line.to_a[1..-2].join +  end + +  # +  # Show the boot options file. +  # +  cmd 'show bof' do |cfg| +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the system information. +  # +  cmd 'show system information' do |cfg| +    # +    # Strip uptime. +    # +    cfg.sub! /^System Up Time.*\n/, '' +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the card state. +  # +  cmd 'show card state' do |cfg| +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the boot log. +  # +  cmd 'file type bootlog.txt' do |cfg| +    # +    # Strip carriage returns and backspaces. +    # +    cfg.gsub! /\r/, '' +    cfg.gsub! /[\b][\b][\b]/, "\n" +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the running debug configuration. +  # +  cmd 'show debug' do |cfg| +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the saved debug configuration (admin debug-save). +  # +  cmd 'file type config.dbg' do |cfg| +    # +    # Strip carriage returns. +    # +    cfg.gsub! /\r/, '' +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the running persistent indices. +  # +  cmd 'admin display-config index' do |cfg| +    # +    # Strip carriage returns. +    # +    cfg.gsub! /\r/, '' +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +    comment cfg +  end + +  # +  # Show the running configuration. +  # +  cmd 'admin display-config' do |cfg| +    # +    # Strip carriage returns. +    # +    cfg.gsub! /\r/, '' +    cfg.gsub! /# Finished .*/, '' +    cfg.gsub! /# Generated .*/, '' +  end + +  cfg :telnet do +    username /^Login: / +    password /^Password: / +  end + +  cfg :telnet, :ssh do +    post_login 'environment no more' +    pre_logout 'logout' +  end +end diff --git a/lib/oxidized/model/supermicro.rb b/lib/oxidized/model/supermicro.rb index 361244c..56d5ef6 100644 --- a/lib/oxidized/model/supermicro.rb +++ b/lib/oxidized/model/supermicro.rb @@ -1,45 +1,10 @@ -class Supermicro < Oxidized::Model -  comment  '! ' +# Backward compatibility shim for deprecated model `supermicro`. +# Migrate your source from `supermicro` to `edgecos`. -  cmd :secret do |cfg| -    cfg.gsub!(/password \d+ (\S+).*/, '<secret removed>') -    cfg.gsub!(/community (\S+)/, 'community <hidden>') -    cfg -  end +require_relative 'edgecos.rb' -  cmd :all do |cfg| -     cfg.each_line.to_a[2..-2].join -  end +Supermicro = EdgeCOS -  cmd 'show running-config' +Oxidized.logger.warn "Using deprecated model supermicro, use edgecos instead." -  cmd 'show access-list tcam-utilization' do |cfg| -    comment cfg -  end - -  cmd 'show memory' do |cfg| -    comment cfg -  end - -  cmd 'show system' do |cfg| -    comment cfg -  end - -  cmd 'show version' do |cfg| -    comment cfg -  end - -  cmd 'show watchdog' do |cfg| -    comment cfg -  end - -  cfg :telnet do -    username /^Username:/ -    password /^Password:/ -  end - -  cfg :telnet, :ssh do -    post_login 'terminal length 0' -    pre_logout 'exit' -  end -end
\ No newline at end of file +# Deprecated diff --git a/lib/oxidized/model/timos.rb b/lib/oxidized/model/timos.rb index c230a8f..e454630 100644 --- a/lib/oxidized/model/timos.rb +++ b/lib/oxidized/model/timos.rb @@ -1,118 +1,10 @@ -class TiMOS < Oxidized::Model +# Backward compatibility shim for deprecated model `timos`. +# Migrate your source from `timos` to `sros`. -  # -  # Nokia SR OS (TiMOS) (formerly TiMetra, Alcatel, Alcatel-Lucent). -  # Used in 7705 SAR, 7210 SAS, 7450 ESS, 7750 SR, 7950 XRS, and NSP. -  # +require_relative 'sros.rb' -  comment  '# ' +TiMOS = SROS -  prompt /^([-\w\.:>\*]+\s?[#>]\s?)$/ +Oxidized.logger.warn "Using deprecated model timos, use sros instead." -  cmd :all do |cfg, cmdstring| -    new_cfg = comment "COMMAND: #{cmdstring}\n" -    new_cfg << cfg.each_line.to_a[1..-2].join -  end - -  # -  # Show the boot options file. -  # -  cmd 'show bof' do |cfg| -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the system information. -  # -  cmd 'show system information' do |cfg| -    # -    # Strip uptime. -    # -    cfg.sub! /^System Up Time.*\n/, '' -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the card state. -  # -  cmd 'show card state' do |cfg| -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the boot log. -  # -  cmd 'file type bootlog.txt' do |cfg| -    # -    # Strip carriage returns and backspaces. -    # -    cfg.gsub! /\r/, '' -    cfg.gsub! /[\b][\b][\b]/, "\n" -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the running debug configuration. -  # -  cmd 'show debug' do |cfg| -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the saved debug configuration (admin debug-save). -  # -  cmd 'file type config.dbg' do |cfg| -    # -    # Strip carriage returns. -    # -    cfg.gsub! /\r/, '' -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the running persistent indices. -  # -  cmd 'admin display-config index' do |cfg| -    # -    # Strip carriage returns. -    # -    cfg.gsub! /\r/, '' -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -    comment cfg -  end - -  # -  # Show the running configuration. -  # -  cmd 'admin display-config' do |cfg| -    # -    # Strip carriage returns. -    # -    cfg.gsub! /\r/, '' -    cfg.gsub! /# Finished .*/, '' -    cfg.gsub! /# Generated .*/, '' -  end - -  cfg :telnet do -    username /^Login: / -    password /^Password: / -  end - -  cfg :telnet, :ssh do -    post_login 'environment no more' -    pre_logout 'logout' -  end -end +# Deprecated diff --git a/lib/oxidized/model/vyatta.rb b/lib/oxidized/model/vyatta.rb index 8d977aa..57ec9d3 100644 --- a/lib/oxidized/model/vyatta.rb +++ b/lib/oxidized/model/vyatta.rb @@ -9,11 +9,15 @@ class Vyatta < Oxidized::Model    end    cmd :secret do |cfg| +    cfg.gsub! /encrypted-password (\S+).*/, 'encrypted-password <secret removed>' +    cfg.gsub! /plaintext-password (\S+).*/, 'plaintext-password <secret removed>' +    cfg.gsub! /password (\S+).*/, 'password <secret removed>' +    cfg.gsub! /pre-shared-secret (\S+).*/, 'pre-shared-secret <secret removed>'      cfg.gsub! /community (\S+) {/, 'community <hidden> {'      cfg    end -  cmd 'show configuration | no-more' +  cmd 'show configuration commands | no-more'    cfg :telnet do      username  /login:\s/ | 
