8000 Added aoscx.rb model by jmurphy5 · Pull Request #2163 · ytti/oxidized · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added aoscx.rb model #2163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- model for eltex mes-series switches (@glaubway)
- model for zte c300 and c320 olt (@glaubway)
- model for LANCOM (@systeembeheerder)
- model for Aruba CX switches (@jmurphy5)

### Changed

Expand Down
1 change: 1 addition & 0 deletions docs/Supported-OS-Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Arris
* [C4CMTS](/lib/oxidized/model/c4cmts.rb)
* Aruba
* [AOS-CX](/lib/oxidized/model/aoscx.rb)
* [AOSW](/lib/oxidized/model/aosw.rb)
* AudioCodes
* [AudioCodes](/lib/oxdized/model/audiocodes.rb)
Expand Down
92 changes: 92 additions & 0 deletions lib/oxidized/model/aoscx.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
class Aoscx < Oxidized::Model
# previous command is repeated followed by "\eE", which sometimes ends up on last line
# ssh switches prompt may start with \r, followed by the prompt itself, regex ([\w\s.-]+[#>] ), which ends the line
# telnet switchs may start with various vt100 control characters, regex (\e\[24;[0-9][hH]), follwed by the prompt, followed
# by at least 3 other vt100 characters
prompt /(^\r|\e\[24;[0-9][hH])?([\w\s.-]+[#>] )($|(\e\[24;[0-9][0-9]?[hH]){3})/

comment '! '

# replace next line control sequence with a new line
expect /(\e\[1M\e\[\??\d+(;\d+)*[A-Za-z]\e\[1L)|(\eE)/ do |data, re|
data.gsub re, "\n"
end

# replace all used vt100 control sequences
expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re|
data.gsub re, ''
end

expect /Press any key to continue(\e\[\??\d+(;\d+)*[A-Za-z])*$/ do
send ' '
""
end

expect /Enter switch number/ do
send "\n"
""
end

cmd :all do |cfg|
cfg = cfg.cut_both
cfg = cfg.gsub /^\r/, ''
# Additional filtering for elder switches sending vt100 control chars via telnet
cfg.gsub! /\e\[\??\d+(;\d+)*[A-Za-z]/, ''
# Additional filtering for power usage reporting which obviously changes over time
cfg.gsub! /^(.*AC [0-9]{3}V\/?([0-9]{3}V)?) *([0-9]{1,3}) (.*)/, '\\1 <removed> \\4'
cfg
end

cmd :secret do |cfg|
cfg.gsub! /^(snmp-server community) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(snmp-server host \S+) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(radius-server host \S+ key) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(radius-server key).*/, '\\1 <configuration removed>'
cfg.gsub! /^(tacacs-server host \S+ key) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(tacacs-server key).*/, '\\1 <secret hidden>'
cfg
end

cmd 'show version' do |cfg|
comment cfg
end

cmd ' show environment' do |cfg|
comment cfg
end

cmd 'show module' do |cfg|
comment cfg
end

cmd 'show interface transceiver' do |cfg|
comment cfg
end

cmd 'show system' do |cfg|
comment cfg
end

cmd 'show running-config'

cfg :telnet do
username /Username:/
password /Password:/
end

cfg :telnet, :ssh do
# preferred way to handle additional passwords
if vars :enable
post_login do
send "enable\n"
cmd vars(:enable)
end
end
post_login 'no page'
pre_logout "exit"
end

cfg :ssh do
pty_options(chars_wide: 1000)
end
end
0