diff options
Diffstat (limited to 'lib/oxidized')
| -rw-r--r-- | lib/oxidized/input/ssh.rb | 19 | ||||
| -rw-r--r-- | lib/oxidized/model/alteonos.rb | 60 | ||||
| -rw-r--r-- | lib/oxidized/model/asa.rb | 71 | ||||
| -rw-r--r-- | lib/oxidized/model/asyncos.rb | 49 | ||||
| -rw-r--r-- | lib/oxidized/model/audiocodes.rb | 32 | ||||
| -rw-r--r-- | lib/oxidized/model/ciscosma.rb | 45 | ||||
| -rw-r--r-- | lib/oxidized/model/ciscosmb.rb | 5 | ||||
| -rw-r--r-- | lib/oxidized/model/dlink.rb | 1 | ||||
| -rw-r--r-- | lib/oxidized/model/enterasys.rb | 30 | ||||
| -rw-r--r-- | lib/oxidized/model/fortios.rb | 2 | ||||
| -rw-r--r-- | lib/oxidized/model/hpemsa.rb | 13 | ||||
| -rw-r--r-- | lib/oxidized/model/ipos.rb | 8 | ||||
| -rw-r--r-- | lib/oxidized/model/ironware.rb | 3 | ||||
| -rw-r--r-- | lib/oxidized/model/netgear.rb | 16 | ||||
| -rw-r--r-- | lib/oxidized/model/panos.rb | 2 | ||||
| -rw-r--r-- | lib/oxidized/model/planet.rb | 3 | ||||
| -rw-r--r-- | lib/oxidized/model/procurve.rb | 13 | ||||
| -rw-r--r-- | lib/oxidized/model/routeros.rb | 13 | ||||
| -rw-r--r-- | lib/oxidized/model/ucs.rb | 31 | ||||
| -rw-r--r-- | lib/oxidized/model/voss.rb | 16 | ||||
| -rw-r--r-- | lib/oxidized/model/weos.rb | 22 | ||||
| -rw-r--r-- | lib/oxidized/model/xos.rb | 4 | 
22 files changed, 414 insertions, 44 deletions
| diff --git a/lib/oxidized/input/ssh.rb b/lib/oxidized/input/ssh.rb index 858d5cd..27e81e0 100644 --- a/lib/oxidized/input/ssh.rb +++ b/lib/oxidized/input/ssh.rb @@ -24,20 +24,23 @@ module Oxidized        secure = Oxidized.config.input.ssh.secure        @log = File.open(Oxidized::Config::Log + "/#{@node.ip}-ssh", 'w') if Oxidized.config.input.debug?        port = vars(:ssh_port) || 22 +       +      ssh_opts = { +                :port => port.to_i, +                :password => @node.auth[:password], :timeout => Oxidized.config.timeout, +                :paranoid => secure, +                :auth_methods => %w(none publickey password keyboard-interactive), +                :number_of_password_prompts => 0, +        } +        if proxy_host = vars(:ssh_proxy)          proxy_command =  "ssh "          proxy_command += "-o StrictHostKeyChecking=no " unless secure          proxy_command += "#{proxy_host} -W %h:%p"          proxy =  Net::SSH::Proxy::Command.new(proxy_command) +        ssh_opts[:proxy] = proxy        end -      ssh_opts = { -        :port => port.to_i, -        :password => @node.auth[:password], :timeout => Oxidized.config.timeout, -        :paranoid => secure, -        :auth_methods => %w(none publickey password keyboard-interactive), -        :number_of_password_prompts => 0, -        :proxy => proxy, -      } +        ssh_opts[:keys] = vars(:ssh_keys).is_a?(Array) ? vars(:ssh_keys) : [vars(:ssh_keys)] if vars(:ssh_keys)        ssh_opts[:kex]  = vars(:ssh_kex).split(/,\s*/) if vars(:ssh_kex)        ssh_opts[:encryption] = vars(:ssh_encryption).split(/,\s*/) if vars(:ssh_encryption) diff --git a/lib/oxidized/model/alteonos.rb b/lib/oxidized/model/alteonos.rb new file mode 100644 index 0000000..9eacf4e --- /dev/null +++ b/lib/oxidized/model/alteonos.rb @@ -0,0 +1,60 @@ +class ALTEONOS < Oxidized::Model + +  prompt  /^\(?.+\)?\s?[#>]/ + +  comment '! ' + +  cmd :secret do |cfg| +    cfg.gsub!(/^([\s\t]*admpw ).*/, '\1 <password removed>') +    cfg.gsub!(/^([\s\t]*pswd ).*/, '\1 <password removed>') +    cfg.gsub!(/^([\s\t]*esecret ).*/, '\1 <password removed>') +    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.                                                # +  ##                                                                                           # +  ############################################################################################## + +  cmd 'cfg/dump' do |cfg| +    cfg.gsub! /^([\s\t\/*]*Configuration).*/, '' +    cfg.gsub! /^([\s\t\/*]*Version).*/, '' +    cfg.gsub! /^([\s\t\/*]*To restore ).*/, '' +    cfg.gsub! /^([\s\t\/*]*it is recommended to include).*/, '' +    cfg.gsub! /^([\s\t\/*]*to include ).*/, '' +    cfg +  end + +  #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 +  expect /^Confirm Sync to Peer\s?\[y\/n\]\: $/ do |data, re| +    send "n\r" +    data.sub re, '' +  end + +  #Answer for  Unsaved configuration  +  expect /^(WARNING: There are unsaved configuration changes).*/ do |data, re| +    send "n\r" +    data.sub re, '' +  end + +  cfg :ssh do +    pre_logout 'exit' +  end + +end diff --git a/lib/oxidized/model/asa.rb b/lib/oxidized/model/asa.rb index 038dd6b..9df4206 100644 --- a/lib/oxidized/model/asa.rb +++ b/lib/oxidized/model/asa.rb @@ -20,6 +20,11 @@ class ASA < Oxidized::Model      cfg    end +  # check for multiple contexts +  cmd 'show mode' do |cfg| +    @is_multiple_context = cfg.include? 'multiple' +  end +    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.*)/ } @@ -31,25 +36,12 @@ class ASA < Oxidized::Model      comment cfg    end -  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 +  post do +    if @is_multiple_context +      multiple_context +    else +      single_context      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 -    cfg    end    cfg :ssh do @@ -62,5 +54,48 @@ 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 +        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 +        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 +          end +          cfg = allcfg +        end +        cfg +      end +  end  end diff --git a/lib/oxidized/model/asyncos.rb b/lib/oxidized/model/asyncos.rb new file mode 100644 index 0000000..875690b --- /dev/null +++ b/lib/oxidized/model/asyncos.rb @@ -0,0 +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 + +	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 diff --git a/lib/oxidized/model/audiocodes.rb b/lib/oxidized/model/audiocodes.rb new file mode 100644 index 0000000..b7ee70e --- /dev/null +++ b/lib/oxidized/model/audiocodes.rb @@ -0,0 +1,32 @@ +class AudioCodes < Oxidized::Model + +# Pull config from AudioCodes Mediant devices from version > 7.0 + +  prompt /^\r?([\w.@() -]+[#>]\s?)$/ +  comment  '## ' + +  expect /\s*--MORE--$/ do |data, re| + +    send ' ' + +    data.sub re, '' + +  end + +  cmd 'show running-config' do |cfg| +   cfg +  end + +  cfg :ssh do +    username /^login as:\s$/ +    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/ciscosma.rb b/lib/oxidized/model/ciscosma.rb new file mode 100644 index 0000000..a52e38a --- /dev/null +++ b/lib/oxidized/model/ciscosma.rb @@ -0,0 +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 + +	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 diff --git a/lib/oxidized/model/ciscosmb.rb b/lib/oxidized/model/ciscosmb.rb index e5501d5..5ddcfcb 100644 --- a/lib/oxidized/model/ciscosmb.rb +++ b/lib/oxidized/model/ciscosmb.rb @@ -16,12 +16,17 @@ class CiscoSMB < Oxidized::Model    cmd :secret do |cfg|      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    end    cmd 'show version' do |cfg|      comment cfg    end +   +  cmd 'show bootvar' do |cfg| +    comment cfg +  end    cmd 'show running-config' do |cfg|      cfg = cfg.each_line.to_a[0..-1].join diff --git a/lib/oxidized/model/dlink.rb b/lib/oxidized/model/dlink.rb index 5756bad..0d08793 100644 --- a/lib/oxidized/model/dlink.rb +++ b/lib/oxidized/model/dlink.rb @@ -15,6 +15,7 @@ class Dlink < Oxidized::Model    end    cmd 'show switch' do |cfg| +    cfg.gsub! /^System\ Uptime\s.+/, '' # Omit constantly changing uptime info      comment cfg    end diff --git a/lib/oxidized/model/enterasys.rb b/lib/oxidized/model/enterasys.rb new file mode 100644 index 0000000..708d380 --- /dev/null +++ b/lib/oxidized/model/enterasys.rb @@ -0,0 +1,30 @@ +class Enterasys < Oxidized::Model + +  # Enterasys B3/C3 models # + +  prompt /^.+\w\(su\)->\s?$/ + +  comment  '!' + +  cmd :all do |cfg| +     cfg.each_line.to_a[2..-3].map{|line|line.delete("\r").rstrip}.join("\n") + "\n" +  end + +  cmd 'show system hardware' do |cfg| +    comment cfg +  end + +  cmd 'show config' do |cfg| +    cfg.gsub! /^This command shows non-default configurations only./, '' +    cfg.gsub! /^Use 'show config all' to show both default and non-default configurations./, '' +    cfg.gsub! /^!|#.*/, '' +    cfg.gsub! /^$\n/, '' + +    cfg +  end + +  cfg :ssh do +    pre_logout 'exit' +  end + +end diff --git a/lib/oxidized/model/fortios.rb b/lib/oxidized/model/fortios.rb index 0249933..2d15aae 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 ENC)).*/, '\\1 <configuration removed>' +    cfg.gsub! /(set (?:passwd|password|secondary-secret|rsso-secret|psksecret|secret|key ENC)).*/, '\\1 <configuration removed>'      cfg.gsub! /(set private-key).*-+END ENCRYPTED PRIVATE KEY-*"$/m , '\\1 <configuration removed>'      cfg    end diff --git a/lib/oxidized/model/hpemsa.rb b/lib/oxidized/model/hpemsa.rb new file mode 100644 index 0000000..4fe636f --- /dev/null +++ b/lib/oxidized/model/hpemsa.rb @@ -0,0 +1,13 @@ +class HpeMsa < Oxidized::Model + +  prompt /^#\s?$/ + +  cmd 'show configuration' + +  cfg :ssh do +    post_login 'set cli-parameters pager disabled' +    pre_logout 'exit' +  end + +end + diff --git a/lib/oxidized/model/ipos.rb b/lib/oxidized/model/ipos.rb index 5efd831..938f12d 100644 --- a/lib/oxidized/model/ipos.rb +++ b/lib/oxidized/model/ipos.rb @@ -3,7 +3,7 @@ class IPOS < Oxidized::Model    # Ericsson SSR (IPOS)    # Redback SE (SEOS) -  prompt /^([\[\]\w.@-]+[#>]\s?)$/ +  prompt /^([\[\]\w.@-]+[#:>]\s?)$/    comment '! '    cmd 'show chassis' do |cfg| @@ -52,6 +52,12 @@ class IPOS < Oxidized::Model    cfg :telnet, :ssh do      post_login 'terminal length 0' +    if vars :enable +      post_login do +        cmd "enable"  +        cmd vars(:enable) +      end +    end      pre_logout do        send "exit\n"        send "n\n" diff --git a/lib/oxidized/model/ironware.rb b/lib/oxidized/model/ironware.rb index c3540da..386d585 100644 --- a/lib/oxidized/model/ironware.rb +++ b/lib/oxidized/model/ironware.rb @@ -34,6 +34,8 @@ class IronWare < Oxidized::Model      cfg.gsub! /(^((.*)Current temp(.*))$)/, '' #remove unwanted lines current temperature      cfg.gsub! /Speed = [A-Z-]{2,6} \(\d{2,3}\%\)/, '' #remove unwanted lines Speed Fans      cfg.gsub! /current speed is [A-Z]{2,6} \(\d{2,3}\%\)/, '' +    cfg.gsub! /Fan \d* - STATUS: OK \D*\d*./, '' # Fix for ADX Fan speed reporting +    cfg.gsub! /\d* deg C/, '' # Fix for ADX temperature reporting      cfg.gsub! /([\[]*)1([\]]*)<->([\[]*)2([\]]*)(<->([\[]*)3([\]]*))*/, ''      cfg.gsub! /\d{2}\.\d deg-C/, 'XX.X deg-C'      if cfg.include? "TEMPERATURE" @@ -50,6 +52,7 @@ class IronWare < Oxidized::Model    end    cmd 'show flash' do |cfg| +    cfg.gsub! /(\d+) bytes/, '' # Fix for ADX flash size      comment cfg    end diff --git a/lib/oxidized/model/netgear.rb b/lib/oxidized/model/netgear.rb index 08c64d3..38aaca7 100644 --- a/lib/oxidized/model/netgear.rb +++ b/lib/oxidized/model/netgear.rb @@ -8,21 +8,29 @@ class Netgear < Oxidized::Model      cfg    end +  cfg :telnet do +    username /^User:/ +  end +    cfg :telnet, :ssh do      if vars :enable        post_login do -        cmd 'enable' +        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?$/ -          cmd vars(:enable) + "\n" +          send vars(:enable) + "\n"          end          expect /^.+[#]$/        end      end      post_login 'terminal length 0' -    pre_logout 'exit' -    pre_logout 'quit' +    # quit / logout will sometimes prompt the user: +    # +    #     The system has unsaved changes. +    #     Would you like to save them now? (y/n) +    # +    # So it is safer simply to disconnect and not issue a pre_logout command    end    cmd 'show running-config' do |cfg| diff --git a/lib/oxidized/model/panos.rb b/lib/oxidized/model/panos.rb index 68d80c3..67ccaec 100644 --- a/lib/oxidized/model/panos.rb +++ b/lib/oxidized/model/panos.rb @@ -28,6 +28,6 @@ class PanOS < Oxidized::Model    cfg :ssh do      post_login 'set cli pager off' -    pre_logout 'exit' +    pre_logout 'quit'    end  end diff --git a/lib/oxidized/model/planet.rb b/lib/oxidized/model/planet.rb index 05a369a..9ce9cf9 100644 --- a/lib/oxidized/model/planet.rb +++ b/lib/oxidized/model/planet.rb @@ -39,9 +39,10 @@ class Planet < Oxidized::Model      cfg = cfg.each_line.to_a[0...-2] -   # Strip system time and system uptime from planet gs switches +   # Strip system (up)time and temperature      cfg = cfg.reject { |line| line.match /System Time\s*:.*/ }      cfg = cfg.reject { |line| line.match /System Uptime\s*:.*/ } +    cfg = cfg.reject { |line| line.match /Temperature\s*:.*/ }      comment cfg.join    end diff --git a/lib/oxidized/model/procurve.rb b/lib/oxidized/model/procurve.rb index 7dcf1fd..180b703 100644 --- a/lib/oxidized/model/procurve.rb +++ b/lib/oxidized/model/procurve.rb @@ -30,6 +30,7 @@ class Procurve < Oxidized::Model      cfg.gsub! /^(snmp-server community).*/, '\\1 <configuration removed>'      cfg.gsub! /^(snmp-server host).*/, '\\1 <configuration removed>'      cfg.gsub! /^(radius-server host).*/, '\\1 <configuration removed>' +    cfg.gsub! /^(radius-server key).*/, '\\1 <configuration removed>'      cfg    end @@ -37,6 +38,18 @@ class Procurve < Oxidized::Model      comment cfg    end +  cmd 'show modules' do |cfg| +    comment cfg +  end + +  cmd 'show interfaces transceiver' do |cfg| +    comment cfg +  end + +  cmd 'show flash' do |cfg| +    comment cfg +  end +    # not supported on all models    cmd 'show system-information' do |cfg|      cfg = cfg.split("\n")[0..-8].join("\n") diff --git a/lib/oxidized/model/routeros.rb b/lib/oxidized/model/routeros.rb index 31650c7..f391fb9 100644 --- a/lib/oxidized/model/routeros.rb +++ b/lib/oxidized/model/routeros.rb @@ -14,11 +14,14 @@ class RouterOS < Oxidized::Model      comment cfg    end -  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" +  post do +    run_cmd = vars(:remove_secret) ? '/export hide-sensitive' : '/export' +    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 = cfg.split("\n").select { |line| not line[/^\#\s\w{3}\/\d{2}\/\d{4}.*$/] } +      cfg.join("\n") + "\n" +    end    end    cfg :telnet do diff --git a/lib/oxidized/model/ucs.rb b/lib/oxidized/model/ucs.rb new file mode 100644 index 0000000..a1f6c10 --- /dev/null +++ b/lib/oxidized/model/ucs.rb @@ -0,0 +1,31 @@ +class UCS < Oxidized::Model + +  prompt /^(\r?[\w.@_()-]+[#]\s?)$/ +  comment '! ' + +  cmd 'show version brief' do |cfg| +    comment cfg +  end + +  cmd 'show chassis detail' do |cfg| +    comment cfg +  end + +  cmd 'show fabric-interconnect detail' do |cfg| +    comment cfg +  end + +  cmd 'show configuration all | no-more' do |cfg| +    cfg +  end + +  cfg :ssh, :telnet do +    post_login 'terminal length 0' +    pre_logout 'exit' +  end + +  cfg :telnet do +    username /^login:/ +    password /^Password:/ +  end +end diff --git a/lib/oxidized/model/voss.rb b/lib/oxidized/model/voss.rb index 599462a..6b15fb3 100644 --- a/lib/oxidized/model/voss.rb +++ b/lib/oxidized/model/voss.rb @@ -1,7 +1,7 @@  class Voss < Oxidized::Model    # Avaya VSP Operating System Software(VOSS)    # Created by danielcoxman@gmail.com -  # May 15, 2017 +  # May 25, 2017    # This was tested on vsp4k and vsp8k    comment '# ' @@ -10,10 +10,16 @@ class Voss < Oxidized::Model    # needed for proper formatting after post_login    cmd('') { |cfg| comment "#{cfg}\n" } -  # get some general information about switch -  cmd('show sys-info card') { |cfg| comment "#{cfg}\n" } -  cmd('show sys-info fan') { |cfg| comment "#{cfg}\n" } -  cmd('show sys-info power') { |cfg| comment "#{cfg}\n" } +   +  # Get sys-info and remove information that changes such has temperature and power +  cmd 'show sys-info' do |cfg| +    cfg.gsub! /(^((.*)SysUpTime(.*))$)/, 'removed SysUpTime' +    cfg.gsub! /^((.*)Temperature Info \:(.*\r?\n){4})/, 'removed Temperature Info and 3 more lines' +    cfg.gsub! /(^((.*)AmbientTemperature(.*)\:(.*))$)/, 'removed AmbientTemperature' +    cfg.gsub! /(^((.*)Temperature(.*)\:(.*))$)/, 'removed Temperature' +    cfg.gsub! /(^((.*)Total Power Usage(.*)\:(.*))$)/, 'removed Total Power Usage' +    comment "#{cfg}\n" +  end    # more the config rather than doing a show run    cmd 'more config.cfg' do |cfg| diff --git a/lib/oxidized/model/weos.rb b/lib/oxidized/model/weos.rb new file mode 100644 index 0000000..1b20286 --- /dev/null +++ b/lib/oxidized/model/weos.rb @@ -0,0 +1,22 @@ +class WEOS < Oxidized::Model + +  #Westell WEOS, works with Westell 8178G, Westell 8266G + +  prompt /^(\s[\w.@-]+[#>]\s?)$/ + +  cmd :all do |cfg| +    cfg.each_line.to_a[1..-2].join +  end + +  cmd 'show running-config' do |cfg| +    cfg +  end + +  cfg :telnet do +    username /login:/ +    password /assword:/ +    post_login 'cli more disable' +    pre_logout 'logout' +  end + +end diff --git a/lib/oxidized/model/xos.rb b/lib/oxidized/model/xos.rb index 6f1323f..90f6f4a 100644 --- a/lib/oxidized/model/xos.rb +++ b/lib/oxidized/model/xos.rb @@ -29,6 +29,10 @@ class XOS < Oxidized::Model    cmd 'show configuration' +  cmd 'show policy detail' do |cfg| +    comment cfg +  end +    cfg :telnet do      username /^login:/      password /^\r*password:/ | 
