Skip to content

Riverbed#3317

Merged
robertcheramy merged 6 commits intoytti:masterfrom
Swaeltjie:riverbed
Nov 16, 2024
Merged

Riverbed#3317
robertcheramy merged 6 commits intoytti:masterfrom
Swaeltjie:riverbed

Conversation

@Swaeltjie
Copy link

Pre-Request Checklist

  • Passes rubocop code analysis (try rubocop --auto-correct)
  • Tests added or adapted (try rake test)
  • Changes are reflected in the documentation
  • User-visible changes appended to CHANGELOG.md

Description

New model for Riverbed Steelheads.

@robertcheramy robertcheramy self-assigned this Nov 14, 2024
Copy link
Collaborator

@robertcheramy robertcheramy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for your PR and also submitting a YAML-Simulation File AND a unit test. I love this, it makes reviewing the PR much easier.

Please have a look at my review and consider updating the model.

# Define comment character
comment '! '

# Use procs to remove unwanted lines
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The "Last login" message should never appear, as Oxidized does not interpret the initial prompt.
  • Do not use procs directly. Use cmd :all

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the entire procs block.


# Remove sensitive information
cmd :secret do |cfg|
cfg.gsub! /^(\s*tacacs-server (.+ )?key) .+/, '\\1 <secret hidden>'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer space to \s when possible, as \s also matches \n and \r

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced \s with explicit spaces to match only space characters.

cmd 'show hardware all' do |cfg|
# Remove the command echo and the hostname from the output
cfg = cfg.cut_head
cfg.gsub!(PROMPT, '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using cut_both

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with cfg = cfg.cut_both to remove both the first and last lines in one step.


# Prepend date, version, hardware, and serial information to the configuration
header = []
header << comment("Date of version: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %Z')}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printing the time is not a good idea, as oxidized will store a config after every fetch. The idea is to strip everything changing out, and store the configs in git, so you only get differences and not thousand of identical files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the line that adds the date to the header.

# Prepend date, version, hardware, and serial information to the configuration
header = []
header << comment("Date of version: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %Z')}")
header << comment(@serial_info) if @serial_info
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to output these informations above and not store them into a variable? Most other models do so.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified the code to output the extracted information directly as comments within the cmd blocks.

- Simplified the prompt definition.
- Replaced `\s` with explicit spaces in regex patterns.
- Used `cut_both` to simplify output trimming.
- Removed dynamic date to prevent unnecessary diffs.
- Outputted extracted information directly as comments.
@Swaeltjie
Copy link
Author

Thank you for taking the time to review the PR. It's my first time doing this.

I've updated the file with all the recommendations and replied to all comments. Tested and all is working as expected.

- Fixes rubocop warnings
- use "cfg = cfg.cut_both" everywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants