Optimize IP OSPF Parsers
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
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:
Show IP OSPF Neighbours Detail:
Checklist:
- [x] I have updated the changelog.
- [ ] I have updated the documentation (If applicable).
- [ ] I have added tests to cover my changes (If applicable).
- [x] All new and existing tests passed.
- [x] All new code passed compilation.
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.