feat: Nokia SR OS interface/BGP/OSPF CLI parsers#15
Conversation
Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com> Agent-Logs-Url: https://github.com/plures/netops-toolkit/sessions/4566166d-0f06-4a8e-96d4-47b392ae0b7d
kayodebristol
left a comment
There was a problem hiding this comment.
Good implementation. Nokia parsers align well with the Cisco convention. A few suggestions below.
…coverage - Added __all__ to nokia_sros.py for explicit public API - Exposed link (Layer 1) state as separate bool field in parse_interfaces - Added link assertions in test_parsers_nokia.py for all interface cases
kayodebristol
left a comment
There was a problem hiding this comment.
All 3 suggestions applied in c1d6fed and conversations resolved. Nokia parsers look production-ready.
There was a problem hiding this comment.
Pull request overview
Adds Nokia SR OS CLI parsing support to the netops toolkit, enabling structured extraction of interface, BGP, and OSPF operational state with field names aligned to existing Cisco-oriented consumers.
Changes:
- Added
netops/parsers/nokia_sros.pywith parsers forshow port,show router bgp summary, andshow router ospf neighbor. - Added pytest coverage for the Nokia SR OS parsers using representative CLI output fixtures.
- Updated
netops/check/interfaces.pyto use the Nokia interface parser and avoidKeyErrorwhen anipfield is absent.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/test_parsers_nokia.py |
Adds unit tests and fixtures validating Nokia SR OS parsing behavior. |
netops/parsers/nokia_sros.py |
Implements the three Nokia SR OS CLI parsers and normalizes output fields for consumers. |
netops/parsers/__init__.py |
Initializes the netops.parsers package with a module docstring. |
netops/check/interfaces.py |
Wires Nokia interface parsing into the interface check path and hardens display output for missing ip. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import pytest | ||
|
|
There was a problem hiding this comment.
pytest is imported but never used in this test module. With Ruff enabled in pyproject.toml, this will be flagged as an unused import (F401). Remove the import or use it (e.g., pytest.mark/fixtures) if needed.
| import pytest |
| # TODO: Nokia parser | ||
| result["raw"] = output | ||
| all_interfaces = parse_nokia_interfaces(output) | ||
| interfaces = [i for i in all_interfaces if not i["up"]] if down_only else all_interfaces |
There was a problem hiding this comment.
This conditional list-comprehension line is quite long and harder to read/maintain (and likely exceeds the project’s 100-char Ruff line-length setting). Consider expanding it into a small if down_only: block or splitting across lines for clarity.
| interfaces = [i for i in all_interfaces if not i["up"]] if down_only else all_interfaces | |
| if down_only: | |
| interfaces = [i for i in all_interfaces if not i["up"]] | |
| else: | |
| interfaces = all_interfaces |
Adds structured parsing of Nokia SR OS CLI output for the three core operational tables, with field names aligned to the existing Cisco parser convention.
New:
netops/parsers/nokia_sros.pyparse_interfaces()show portname,status,protocol,upparse_bgp_summary()show router bgp summaryneighbor,peer_as,state,received,sent,active,up_down,descriptionparse_ospf_neighbors()show router ospf neighborinterface,router_id,state,priority,retx_queueparse_interfacesdeliberately mirrorsparse_cisco_interfacesfield names (status/protocol/up) so callers can handle both vendors uniformly without branching on vendor type.Updated:
netops/check/interfaces.py# TODO: Nokia parserstub with a real implementation backed byparse_interfaces(); Nokia devices now populateinterfaces,summary, andsuccessidentically to the Cisco path.KeyErroroniface["ip"]in the display loop — Nokia ports carry noipkey, changed toiface.get("ip").Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.