ytti / oxidized

Oxidized is a network device configuration backup tool. It's a RANCID replacement!
Apache License 2.0
2.8k stars 925 forks source link

Cisco SmallBusiness is not working #3044

Closed bueste closed 4 months ago

bueste commented 9 months ago

Tested on SB250+SB350 and various CBS Switches.

I hat to outcoment:

  if vars(:enable) == true
    cmd 'enable'
  elsif vars(:enable)
    cmd 'enable', /^\r?Password:$/
    cmd vars(:enable)
  end

Those switches haven't an enable comment...

robertcheramy commented 9 months ago

We need a model maintainer for Cisco SMB who could work on this issue.

bueste commented 9 months ago

This change work for all SG and CBS Switches. Only the CBS220 is not working.

bueste commented 9 months ago

I could fix it and I have create a new Model for the cisco cbs220 series.

`class CiscoSMBCBS < Oxidized::Model using Refinements

Cisco Small Business CBS220 series switches

https://www.cisco.com/c/en/us/support/switches/business-220-series-smart-switches/series.html

prompt /^[^\r\n]+[#>]/ comment '! '

cmd :all do |cfg| lines = cfg.each_line.to_a[1..-2]

Remove \r from beginning of response

lines[0].gsub!(/^\r.*?/, '') unless lines.empty?
lines.join

end

cmd :secret do |cfg| cfg.gsub! /^(snmp-server community)./, '\1 ' cfg.gsub! /username (\S+) privilege (\d+) (\S+)./, '

cmd 'show version' do |cfg| cfg.gsub! /.Uptime for this control./, '' cfg.gsub! /.System restarted./, '' cfg.gsub! /uptime is\ .+/, '' 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 cfg.gsub! /^Current configuration : [^\n]\n/, '' cfg.sub! /^(ntp clock-period)./, '! \1' cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]\n( (?: [^\n]\n)* tunnel mpls traffic-eng auto-bw)/mx, '\1' cfg 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 end ` Could you pull it to the production tree?

bueste commented 9 months ago

Issue for the Cisco SMB SG Series fix:

`class CiscoSMB < Oxidized::Model using Refinements

Cisco Small Business 300, 500, and ESW2 series switches

http://www.cisco.com/c/en/us/support/switches/small-business-300-series-managed-switches/products-release-notes-list.html

prompt /^\r?([\w.@()-]+[#>]\s?)$/ comment '! '

cmd :all do |cfg| lines = cfg.each_line.to_a[1..-2]

Remove \r from beginning of response

lines[0].gsub!(/^\r.*?/, '') unless lines.empty?
lines.join

end

cmd :secret do |cfg| cfg.gsub! /^(snmp-server community)./, '\1 ' cfg.gsub! /username (\S+) privilege (\d+) (\S+)./, '

cmd 'show version' do |cfg| cfg.gsub! /.Uptime for this control./, '' cfg.gsub! /.System restarted./, '' cfg.gsub! /uptime is\ .+/, '' 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 cfg.gsub! /^Current configuration : [^\n]\n/, '' cfg.sub! /^(ntp clock-period)./, '! \1' cfg.gsub! /^ tunnel mpls traffic-eng bandwidth[^\n]\n( (?: [^\n]\n)* tunnel mpls traffic-eng auto-bw)/mx, '\1' cfg 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 end `

robertcheramy commented 9 months ago

This is great! Can you please submit a Pull Request? For Instructions see at https://github.com/ytti/oxidized/blob/master/CONTRIBUTING.md#how-to-contribute-content If something is not clear, just ask, I'll be happy to complete the instructions.

systeembeheerder commented 8 months ago

Tested on SB250+SB350 and various CBS Switches.

I hat to outcoment:

Running CBS and SG Switches here without problems. No need to outcomment.