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

Optimize IP OSPF Parsers #780

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

virrsa
Copy link
Contributor

@virrsa virrsa commented Aug 18, 2023

Description

Optimized show ip ospf interfaces and show ip ospf neighbours detail parser to prevent parser from calling additional commands multiple times, speeding up the parsing. Additional commands needed for parsing are now called once at the beginning of the parser.

Resolves #746 and resolves #747

Motivation and Context

This change was made because the parsers were running for 15+ minutes for a single command on switches with many interfaces and/or neighbours, and device CPU spiked up to 100% for the entire duration due to the amount of commands that were being called throughout the parsing process.

Impact (If any)

Passes the load of parsing to the device running the parser rather than the network device.
Ex. Instead of running "show running-config | section router ospf " for all instances of ospf on the network device, the parser executes "show running-config | section router ospf" once and uses the output to search for every instance needed.

Screenshots:

There were no unit tests for these commands, so I tested the current and optimized parser on live devices, and compared the outputs to see if they were the same.

The only changes present are timers, as shown in the screenshots below. If you look to the side, you can see that the "changes" are all timers and are consistent.

Show IP OSPF Interfaces:
InkedMicrosoftTeams-image

Show IP OSPF Neighbours Detail:
InkedMicrosoftTeams-image (1)

Checklist:

  • I have updated the changelog.
  • I have updated the documentation (If applicable).
  • I have added tests to cover my changes (If applicable).
  • All new and existing tests passed.
  • All new code passed compilation.

Copy link
Collaborator

@ThomasJRyan ThomasJRyan left a comment

Choose a reason for hiding this comment

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

Huh... I wonder how such an unoptimized parser made it in in the first place. Thank you for addressing this!

If you wouldn't mind adding in a unittest or two to verify this works as expected we would greatly appreciate it!

src/genie/libs/parser/iosxe/show_ospf.py Outdated Show resolved Hide resolved
@virrsa
Copy link
Contributor Author

virrsa commented Sep 18, 2023

I attempted to run the unit tests for the two parsers, but one is empty and one does not exist. I played around with it and it looks like the folder parsing job can't accommodate parsers that call multiple commands within the parser itself. I have the output for Show IP OSPF Interfaces here, however, it is empty.

python3 folder_parsing_job.py -o iosxe -c ShowIpOspfInterface
2023-09-17T20:40:21: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:21: %AETEST-INFO: |                   Starting testcase SuperFileBasedTesting                    |
2023-09-17T20:40:21: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:21: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:21: %AETEST-INFO: |                            Starting section setup                            |
2023-09-17T20:40:21: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:22: %SCRIPT-WARNING: Equal unittests for iosxe -> ShowIpOspfInterface don't exist
2023-09-17T20:40:23: %AETEST-INFO: The result of section setup is => PASSED
2023-09-17T20:40:23: %AETEST-INFO: The result of testcase SuperFileBasedTesting is => PASSED
2023-09-17T20:40:23: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %AETEST-INFO: |                           Starting testcase iosxe                            |
2023-09-17T20:40:23: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %AETEST-INFO: |                            Starting section setup                            |
2023-09-17T20:40:23: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %AETEST-INFO: The result of section setup is => PASSED
2023-09-17T20:40:23: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %AETEST-INFO: |                           Starting section cleanup                           |
2023-09-17T20:40:23: %AETEST-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %AETEST-INFO: The result of section cleanup is => PASSED
2023-09-17T20:40:23: %AETEST-INFO: The result of testcase iosxe is => PASSED
2023-09-17T20:40:23: %GENIE-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %GENIE-INFO: |                               Unittest results                               |
2023-09-17T20:40:23: %GENIE-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %GENIE-INFO:  SECTIONS/TESTCASES                                                      RESULT   
2023-09-17T20:40:23: %GENIE-INFO: --------------------------------------------------------------------------------
2023-09-17T20:40:23: %GENIE-INFO: .
2023-09-17T20:40:23: %GENIE-INFO: |-- SuperFileBasedTesting                                                 PASSED
2023-09-17T20:40:23: %GENIE-INFO: |   `-- setup                                                             PASSED
2023-09-17T20:40:23: %GENIE-INFO: `-- iosxe                                                                 PASSED
2023-09-17T20:40:23: %GENIE-INFO:     |-- setup                                                             PASSED
2023-09-17T20:40:23: %GENIE-INFO:     `-- cleanup                                                           PASSED
2023-09-17T20:40:23: %GENIE-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %GENIE-INFO: |                                   Summary                                    |
2023-09-17T20:40:23: %GENIE-INFO: +------------------------------------------------------------------------------+
2023-09-17T20:40:23: %GENIE-INFO:  Number of ABORTED                                                            0 
2023-09-17T20:40:23: %GENIE-INFO:  Number of BLOCKED                                                            0 
2023-09-17T20:40:23: %GENIE-INFO:  Number of ERRORED                                                            0 
2023-09-17T20:40:23: %GENIE-INFO:  Number of FAILED                                                             0 
2023-09-17T20:40:23: %GENIE-INFO:  Number of PASSED                                                             2 
2023-09-17T20:40:23: %GENIE-INFO:  Number of PASSX                                                              0 
2023-09-17T20:40:23: %GENIE-INFO:  Number of SKIPPED                                                            0 
2023-09-17T20:40:23: %GENIE-INFO:  Total Number                                                                 2 
2023-09-17T20:40:23: %GENIE-INFO:  Success Rate                                                            100.0% 
2023-09-17T20:40:23: %GENIE-INFO: --------------------------------------------------------------------------------
2023-09-17T20:40:23: %GENIE-INFO:  Total Parsers Missing Unittests                                              1 
2023-09-17T20:40:23: %GENIE-INFO: --------------------------------------------------------------------------------
2023-09-17T20:40:23: %GENIE-INFO:  iosxe -> ShowIpOspfInterface
2023-09-17T20:40:23: %GENIE-INFO: --------------------------------------------------------------------------------
2023-09-17T20:40:23: %GENIE-INFO:  Total Passing Unittests                                                      0 
2023-09-17T20:40:23: %GENIE-INFO:  Total Failed Unittests                                                       0 
2023-09-17T20:40:23: %GENIE-INFO:  Total Errored Unittests                                                      0 
2023-09-17T20:40:23: %GENIE-INFO:  Total Unittests                                                              0 
2023-09-17T20:40:23: %GENIE-INFO: --------------------------------------------------------------------------------

If there is anything else you would like me to try, let me know. I have tested the optimized parsers on live devices and they do work (screenshots included in the original PR) just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants