Skip to content

Commit

Permalink
Merge pull request #3317 from Swaeltjie/riverbed
Browse files Browse the repository at this point in the history
Riverbed
  • Loading branch information
robertcheramy authored Nov 16, 2024
2 parents 41ad7c1 + 05e140b commit 3ac0f10
Show file tree
Hide file tree
Showing 3 changed files with 228 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]

### Added
- model for Riverbed Steelhead (@Swaeltjie)
- removed time command from uplink EP4440-DP OLT model
- model for uplink EP4440-DP OLT (@AAm-kun)
- model for Siklu Multihaul TG radios (@bdg-robert)
Expand Down
123 changes: 123 additions & 0 deletions examples/device-simulation/yaml/riverbed_915.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
init_prompt: |-
Riverbed SteelHead
Last login: Fri Nov 1 05:55:01 2024 from 192.0.2.1
steelhead >
commands:
enable: |-
enable
steelhead #
terminal length 0: |-
terminal length 0
steelhead #
terminal width 1024: |-
terminal width 1024
steelhead #
show version: |-
show version
Product name: rbt_sh
Product release: X.Y.Z
Build ID: #1234
Build date: YYYY-MM-DD HH:MM:SS
Build arch: x86_64
Built by: builduser@buildhost
Uptime: 100d 10h 10m 10s
Product model: ModelName (ModelVariant)
System memory: XXXX MB used / XXXX MB free / XXXX MB total
Number of CPUs: XX
CPU load averages: X.XX / X.XX / X.XX
steelhead #
show hardware all: |-
show hardware all
Hardware revision: RevX
Mainboard: MainboardDescription
Slot 0: .......... ModuleDescription0
Slot 1: .......... ModuleDescription1
Slot 2: .......... ModuleDescription2
System led: Color
steelhead #
show info: |-
show info
Current User: admin
Status: Normal
Config: config.bak
Appliance Up Time: 100d 10h 10m 10s
Service Up Time: 90d 20h 20m 20s
Managed by CMC: no
Temperature (C): XX
Serial: SERIAL1234567
Model: ModelName (ModelVariant)
Revision: RevX
Version: X.Y.Z
steelhead #
show running-config: |-
show running-config
##
## Network interface configuration
##
interface inpath0_0 description "Interface Description"
no interface inpath0_0 dhcp
no interface inpath0_0 dhcp dynamic-dns
no interface inpath0_0 dhcpv6
no interface inpath0_0 dhcpv6 dynamic-dns
##
## Secure device access configuration
##
access enable
##
## Port Labels
##
port-label "Label" port "PortNumbers"
tacacs-server host 192.0.2.254 key secretkey
username admin password 7 secretpassword
snmp-server community public
ntp server 192.0.2.100 key 1
ip security shared secret mysecret
!
end
steelhead #
exit: ""
oxidized_output: |
! Date of version: YYYY-MM-DD HH:MM:SS UTC
! Serial: SERIAL1234567
! Product name: rbt_sh
! Product release: X.Y.Z
! Build ID: #1234
! Build date: YYYY-MM-DD HH:MM:SS
! Build arch: x86_64
! Built by: builduser@buildhost
! Product model: ModelName (ModelVariant)
! Number of CPUs: XX
! Hardware revision: RevX
! Mainboard: MainboardDescription
! Slot 0: ModuleDescription0
! Slot 1: ModuleDescription1
! Slot 2: ModuleDescription2
! System led: Color
##
## Network interface configuration
##
interface inpath0_0 description "Interface Description"
no interface inpath0_0 dhcp
no interface inpath0_0 dhcp dynamic-dns
no interface inpath0_0 dhcpv6
no interface inpath0_0 dhcpv6 dynamic-dns
##
## Secure device access configuration
##
access enable
##
## Port Labels
##
port-label "Label" port "PortNumbers"
tacacs-server host 192.0.2.254 key <secret hidden>
username admin password <secret hidden>
snmp-server community <configuration removed>
ntp server 192.0.2.100 key <secret hidden>
ip security shared secret <secret hidden>
!
end
104 changes: 104 additions & 0 deletions lib/oxidized/model/riverbed.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
class Riverbed < Oxidized::Model
using Refinements

# Define the prompt
prompt /^.* *[\w-]+ *[#>] *$/

# Define comment character
comment '! '

# Remove sensitive information
cmd :secret do |cfg|
cfg.gsub! /^( *tacacs-server (.+ )?key) .+/, '\\1 <secret hidden>'
cfg.gsub! /^( *username .+ (password|secret) \d) .+/, '\\1 <secret hidden>'
cfg.gsub! /^( *ntp server .+ key) .+/, '\\1 <secret hidden>'
cfg.gsub! /^( *ntp peer .+ key) .+/, '\\1 <secret hidden>'
cfg.gsub! /^( *snmp-server community).*/, '\\1 <configuration removed>'
cfg.gsub! /^( *ip security shared secret).*/, '\\1 <secret hidden>'
cfg.gsub! /^( *service shared-secret secret client).*/, '\\1 <secret hidden>'
cfg.gsub! /^( *service shared-secret secret server).*/, '\\1 <secret hidden>'
cfg
end

# Get version information and output it as comments
cmd 'show version' do |cfg|
cfg = cfg.cut_both

output = ''
cfg.each_line do |line|
line.strip!
output << comment("Product name: #{Regexp.last_match(1)}\n") if line =~ /^Product name:\s+(.*)$/
output << comment("Product release: #{Regexp.last_match(1)}\n") if line =~ /^Product release:\s+(.*)$/
output << comment("Build ID: #{Regexp.last_match(1)}\n") if line =~ /^Build ID:\s+(.*)$/
output << comment("Build date: #{Regexp.last_match(1)}\n") if line =~ /^Build date:\s+(.*)$/
output << comment("Build arch: #{Regexp.last_match(1)}\n") if line =~ /^Build arch:\s+(.*)$/
output << comment("Built by: #{Regexp.last_match(1)}\n") if line =~ /^Built by:\s+(.*)$/
output << comment("Product model: #{Regexp.last_match(1)}\n") if line =~ /^Product model:\s+(.*)$/
output << comment("Number of CPUs: #{Regexp.last_match(1)}\n") if line =~ /^Number of CPUs:\s+(.*)$/
end
output + "\n"
end

# Get hardware information and output it as comments
cmd 'show hardware all' do |cfg|
cfg = cfg.cut_both

output = ''
cfg.each_line do |line|
line.strip!
output << comment("Hardware revision: #{Regexp.last_match(1)}\n") if line =~ /^Hardware revision:\s+(.*)$/
output << comment("Mainboard: #{Regexp.last_match(1)}\n") if line =~ /^Mainboard:\s+(.*)$/
if line =~ /^Slot (\d+):\s+\.*\s+(.*)$/
slot_number = Regexp.last_match(1)
slot_info = Regexp.last_match(2)
output << comment("Slot #{slot_number}: #{slot_info}\n")
end
output << comment("System led: #{Regexp.last_match(1)}\n") if line =~ /^System led:\s+(.*)$/
end
output + "\n"
end

# Get serial information and output it as comment
cmd 'show info' do |cfg|
cfg = cfg.cut_both

output = ''
cfg.each_line do |line|
line.strip!
output << comment("Serial: #{Regexp.last_match(1)}\n") if line =~ /^Serial:\s+(.*)$/
end
output + "\n"
end

# Get the running configuration
cmd 'show running-config' do |cfg|
cfg = cfg.cut_both

cfg = cfg.each_line.map do |line|
if line =~ /^(.*##.*?##)(.*)$/
comment_part = Regexp.last_match(1).strip
command_part = Regexp.last_match(2).strip
comment_line = comment(comment_part)
if command_part.empty?
comment_line + "\n"
else
comment_line + "\n" + command_part + "\n"
end
else
line
end
end.join

cfg
end

# SSH configuration
cfg :ssh do
post_login do
cmd 'enable'
cmd 'terminal length 0'
cmd 'terminal width 1024'
end
pre_logout 'exit'
end
end

0 comments on commit 3ac0f10

Please sign in to comment.