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

Add new template for Fsas Si-R show ether #1971

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 30 additions & 0 deletions ntc_templates/templates/fsas_sir_show_ether.textfsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Value Required ETHER_GROUP (\d+)
Value Required ETHER_PORT (\d+)
Value DESCRIPTION (\S+)
caribouHY marked this conversation as resolved.
Show resolved Hide resolved
Value STATUS (.+?)
Value STATUS_AUTO (auto)
Copy link
Contributor

@mjbear mjbear Jan 14, 2025

Choose a reason for hiding this comment

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

Support one and two word statuses (ex: offline (backup)).

Suggested change
Value STATUS (.+?)
Value STATUS_AUTO (auto)
Value STATUS (\S+(\s+\S+)?)

Copy link
Contributor

Choose a reason for hiding this comment

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

The "commit suggestion" button can help easily merge in suggestions. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

STATUS have to support the following status:

  • offline
  • offline (backup)
  • offline (startup down)
  • offline (recovery manual)

I added a test case.

Value STATUS_SPEED ([\d]+[MG])
caribouHY marked this conversation as resolved.
Show resolved Hide resolved
Value STATUS_DUPLEX (Full|Half)
Value STATUS_MDI (MDI(-X)?)
Value MEDIA (\S+)
Value FLOW_CONTROL_SEND (\w+)
Value FLOW_CONTROL_RECEIVE (\w+)
Value TYPE (.+?)
Value SINCE (.+?)
Value CONFIG_MODE (\S+)
Value CONFIG_MDI (\S+)
Value CONFIG_MEDIA (\S+)

Start
^\[ETHER -> Continue.Record
^\[ETHER\s+GROUP\-${ETHER_GROUP}\s+PORT\-${ETHER_PORT}\]\s*$$
^description\s+:(\s+${DESCRIPTION})?\s*$$
^status\s+:\s+(${STATUS_AUTO}\s+)?${STATUS_SPEED}\s+${STATUS_DUPLEX}\s+${STATUS_MDI}\s*$$ -> Continue
caribouHY marked this conversation as resolved.
Show resolved Hide resolved
^status\s+:\s+${STATUS}\s*$$
^media\s+:\s+${MEDIA}s*$$
^flow\s+control\s+:\s+(\-|send\s+${FLOW_CONTROL_SEND},\s+receive\s+${FLOW_CONTROL_RECEIVE})\s*$$
caribouHY marked this conversation as resolved.
Show resolved Hide resolved
^type\s+:\s+${TYPE}\s*$$
^since\s+:\s+${SINCE}\s*$$
^config\s+:\s+mode\(${CONFIG_MODE}\),\s+mdi\(${CONFIG_MDI}\),\s+media\(${CONFIG_MEDIA}\)\s*$$
^\s*$$
^. -> Error
1 change: 1 addition & 0 deletions ntc_templates/templates/index
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ fortinet_execute_ping.textfsm, .*, fortinet, exec[[ute]] ping
fortinet_execute_time.textfsm, .*, fortinet, exec[[ute]] ti[[me]]

fsas_sir_show_system_information.textfsm, .*, fsas_sir, sh[[ow]] sys[[tem]] i[[nformation]]
fsas_sir_show_ether.textfsm, .*, fsas_sir, sh[[ow]] eth[[er]]

hp_comware_display_lldp_neighbor-information_verbose.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] v[[erbose]]
hp_comware_display_lldp_neighbor-information_list.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] l[[ist]]
Expand Down
44 changes: 44 additions & 0 deletions tests/fsas_sir/show_ether/fsas_sir_show_ether.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[ETHER GROUP-1 PORT-1]
description : __@@foo
status : 100M Full MDI
media : Metal
flow control : send off, receive on
type : Normal
since : Feb 16 21:28:21 2024
config : mode(100M), mdi(mdi), media(-)

[ETHER GROUP-2 PORT-1]
description :
status : auto 1000M Full MDI
media : Metal
flow control : send off, receive on
type : Backup (group 1, master)
since : Feb 16 21:31:40 2024
config : mode(auto), mdi(auto), media(-)

[ETHER GROUP-2 PORT-2]
description :
status : auto 100M Half MDI-X
media : Metal
flow control : send off, receive off
type : Normal
since : Feb 16 21:28:19 2024
config : mode(auto), mdi(auto), media(-)

[ETHER GROUP-2 PORT-3]
description : ##backup_port##
status : offline (backup)
media : -
flow control : -
type : Backup (group 1, backup)
since : Feb 16 21:36:55 2024
config : mode(auto), mdi(auto), media(-)

[ETHER GROUP-2 PORT-4]
description :
status : disable
media : -
flow control : -
type : Normal
since : Feb 16 21:22:33 2024
config : mode(auto), mdi(auto), media(-)
82 changes: 82 additions & 0 deletions tests/fsas_sir/show_ether/fsas_sir_show_ether.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
parsed_sample:
- config_mdi: "mdi"
config_media: "-"
config_mode: "100M"
description: "__@@foo"
ether_group: "1"
ether_port: "1"
flow_control_receive: "on"
flow_control_send: "off"
media: "Metal"
since: "Feb 16 21:28:21 2024"
status: "100M Full MDI"
status_auto: ""
status_duplex: "Full"
status_mdi: "MDI"
status_speed: "100M"
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit of a bummer the status data is captured twice.
I do notice that's likely because of the offline (backup) and disable statuses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review. Would you prefer not to capture STATUS when not offline or disalble?

Suggested change
status: "100M Full MDI"
status_auto: ""
status_duplex: "Full"
status_mdi: "MDI"
status_speed: "100M"
status: ""
status_auto: ""
status_duplex: "Full"
status_mdi: "MDI"
status_speed: "100M"
  ^status\s+:\s+(${STATUS_AUTO}\s+)?${STATUS_SPEED}\s+${STATUS_DUPLEX}\s+${STATUS_MDI}\s*$$

Copy link
Contributor

@mjbear mjbear Jan 12, 2025

Choose a reason for hiding this comment

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

Thank you for the review. Would you prefer not to capture STATUS when not offline or disalble?

  ^status\s+:\s+(${STATUS_AUTO}\s+)?${STATUS_SPEED}\s+${STATUS_DUPLEX}\s+${STATUS_MDI}\s*$$

@jmcgill298 @jvanderaa @itdependsnetworks
What are your thoughts on the STATUS sometimes capturing data that is captured in other capture groups?

The downside here is that the STATUS capture group would have to become much more rigid (to be the two statuses in the present test data) so it doesn't match the speed/duplex/MDI.

Update: Change sentence grammar.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if the goal is to split the status field into multiple capture groups, then the status field should capture auto, disable, and offline text, and then it would be an empty string if it is set to a particular speed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if the goal is to split the status field into multiple capture groups, then the status field should capture auto, disable, and offline text, and then it would be an empty string if it is set to a particular speed.

I like this idea.
I cooked up some suggestions.

type: "Normal"
- config_mdi: "auto"
config_media: "-"
config_mode: "auto"
description: ""
ether_group: "2"
ether_port: "1"
flow_control_receive: "on"
flow_control_send: "off"
media: "Metal"
since: "Feb 16 21:31:40 2024"
status: "auto 1000M Full MDI"
status_auto: "auto"
status_duplex: "Full"
status_mdi: "MDI"
status_speed: "1000M"
type: "Backup (group 1, master)"
- config_mdi: "auto"
config_media: "-"
config_mode: "auto"
description: ""
ether_group: "2"
ether_port: "2"
flow_control_receive: "off"
flow_control_send: "off"
media: "Metal"
since: "Feb 16 21:28:19 2024"
status: "auto 100M Half MDI-X"
status_auto: "auto"
status_duplex: "Half"
status_mdi: "MDI-X"
status_speed: "100M"
type: "Normal"
- config_mdi: "auto"
config_media: "-"
config_mode: "auto"
description: "##backup_port##"
ether_group: "2"
ether_port: "3"
flow_control_receive: ""
flow_control_send: ""
media: "-"
since: "Feb 16 21:36:55 2024"
status: "offline (backup)"
status_auto: ""
status_duplex: ""
status_mdi: ""
status_speed: ""
type: "Backup (group 1, backup)"
- config_mdi: "auto"
config_media: "-"
config_mode: "auto"
description: ""
ether_group: "2"
ether_port: "4"
flow_control_receive: ""
flow_control_send: ""
media: "-"
since: "Feb 16 21:22:33 2024"
status: "disable"
status_auto: ""
status_duplex: ""
status_mdi: ""
status_speed: ""
type: "Normal"