Skip to content

Commit

Permalink
Add support for ADVA devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephrdev committed May 13, 2022
1 parent 7b5c129 commit 428e1e2
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Dockerfile rebased to phusion/baseimage-docker focal-1.2.0
- model for Lenovo Network OS (@seros1521)
- new option: use_max_threads
- model for ADVA devices (@stephrdev)

### Changed

Expand Down
5 changes: 5 additions & 0 deletions docs/Model-Notes/ADVA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ADVA Configuration

To ensure Oxidized can fetch the configuration, you have to make sure that `cli-paging` is set to `disabled` for the user that is used to connect to the ADVA devices.

Back to [Model-Notes](README.md)
66 changes: 66 additions & 0 deletions lib/oxidized/model/adva.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Oxidized model for ADVA devices
#
# IMPORTANT: To get this working, cli-paging must be disbaled
# # for the user that is used to fetch the configuration.

class ADVA < Oxidized::Model
prompt /ADVA[\w\-]+[#>]\s?$/
comment '# '

cmd :secret do |cfg|
cfg.gsub! /community "[^"]+"/, 'community "<hidden>"'
cfg
end

cmd :all do |cfg|
cfg.cut_both
end

cmd 'show running-config current' do |cfg|
cfg.each_line.reject { |line| line.match /^Preparing configuration file.*/ }.join
end

cmd 'show system' do |cfg|
cfg.each_line.reject { |line| line.match /.*(Local time|Up time).*/ }.join

cfg = "COMMAND: show system\n\n" + cfg
cfg = comment cfg
"\n\n" + cfg
end

cmd 'network-element ne-1'

cmd 'show shelf-info' do |cfg|
cfg = "COMMAND: show shelf-info\n\n" + cfg
cfg = comment cfg
"\n\n" + cfg
end

post do
ports = []
ports_output = ''

cmd 'show ports' do |cfg|
cfg.each_line do |line|
port = line.match(/\|((access|network)[^\|]+)\|/)
ports << port if port
end
end

ports.each do |port|
port_command = 'show ' + port[2] + '-port ' + port[1]

ports_output << cmd(port_command) { |cfg|
cfg = "COMMAND: " + port_command + "\n\n" + cfg
cfg = comment cfg
"\n\n" + cfg
}
end

ports_output
end

cfg :ssh do
pre_logout 'logout'
end
end

0 comments on commit 428e1e2

Please sign in to comment.