Skip to content
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

Extend zynos.rb content #2969

Merged
merged 8 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
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
70 changes: 68 additions & 2 deletions lib/oxidized/model/zynos.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
class ZyNOS < Oxidized::Model
using Refinements

Check warning on line 3 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.0)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:3:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 3 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.1)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:3:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 3 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.2)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:3:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.
prompt /^([\w.@()-<]+[#>]\s?)$/
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
# if there is something you can not identify after prompt, uncomment next line and comment previous line

Check warning on line 5 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.0)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:5:107: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 5 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.1)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:5:107: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 5 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.2)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:5:107: C: Layout/TrailingWhitespace: Trailing whitespace detected.
# prompt /^([\w.@()-<]+[#>]\s?).*$/

comment '! '

# Used in Zyxel DSLAMs, such as SAM1316
# cmd 'config-0'

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

Check warning on line 17 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.0)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:17:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 17 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.1)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:17:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 17 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.2)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:17:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.
# replace all used vt100 control sequences
expect /\e\[\??\d+(;\d+)*[A-Za-z]/ do |data, re|
data.gsub re, ''
end

Check warning on line 22 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.0)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:22:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 22 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.1)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:22:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 22 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.2)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:22:1: C: Layout/TrailingWhitespace: Trailing whitespace detected.
# ignore copyright motd

Check warning on line 23 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.0)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:23:26: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 23 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.1)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:23:26: C: Layout/TrailingWhitespace: Trailing whitespace detected.

Check warning on line 23 in lib/oxidized/model/zynos.rb

View workflow job for this annotation

GitHub Actions / test (3.2)

[rubocop] reported by reviewdog 🐶 Trailing whitespace detected. Raw Output: lib/oxidized/model/zynos.rb:23:26: C: Layout/TrailingWhitespace: Trailing whitespace detected.
expect /^(Copyright .*)\n^([\w.@()-<]+[#>]\s?)$/ do
Dismissed Show dismissed Hide dismissed
Dismissed Show dismissed Hide dismissed
send '\n'
""
end

cmd :all do |cfg|
cfg = cfg.gsub /^\r/, ''
# Additional filtering for elder switches sending vt100 control chars via telnet
cfg.gsub! /\e\[\??\d+(;\d+)*[A-Za-z]/, ''
cfg
end

# remove snmp community, username, password and admin-password
cmd :secret do |cfg|
cfg.gsub! /^(snmp-server get-community) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(snmp-server set-community) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(logins username) \S+(.*) (password) \S+(.*)/, '\\1 <secret hidden> \\2 \\3 <secret hidden> \\4'
cfg.gsub! /^(admin-password) \S+(.*)/, '\\1 <secret hidden> \\2'
cfg.gsub! /^(password) \S+(.*) (privilege \S+)/, '\\1 <secret hidden> \\2 \\3'
cfg
end

cmd 'config-0'
cmd 'show version' do |cfg|
comment cfg
end

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

cmd 'show running-config' do |cfg|
cfg = cfg.split("\n")[4..-2].join("\n")
cfg
end

cfg :telnet do
username /^User name:/i
password /^Password:/i
end

cfg :telnet, :ssh do
post_login do
if vars(:enable) == true
cmd "enable"
elsif vars(:enable)
cmd "enable", /^[pP]assword:/
cmd vars(:enable)
end
end
pre_logout 'exit'
end

cfg :ftp do
end
Expand Down
Loading