Skip to content

feat: Nokia SR OS interface/BGP/OSPF CLI parsers#15

Merged
kayodebristol merged 3 commits intomainfrom
copilot/feat-nokia-sros-bgp-ospf-parsers
Mar 24, 2026
Merged

feat: Nokia SR OS interface/BGP/OSPF CLI parsers#15
kayodebristol merged 3 commits intomainfrom
copilot/feat-nokia-sros-bgp-ospf-parsers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

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.py

Function Command Key output fields
parse_interfaces() show port name, status, protocol, up
parse_bgp_summary() show router bgp summary neighbor, peer_as, state, received, sent, active, up_down, description
parse_ospf_neighbors() show router ospf neighbor interface, router_id, state, priority, retx_queue

parse_interfaces deliberately mirrors parse_cisco_interfaces field names (status/protocol/up) so callers can handle both vendors uniformly without branching on vendor type.

from netops.parsers.nokia_sros import parse_interfaces, parse_bgp_summary, parse_ospf_neighbors

ports = parse_interfaces(conn.send("show port"))
# [{"name": "1/1/1", "status": "Up", "protocol": "Up", "up": True}, ...]

peers = parse_bgp_summary(conn.send("show router bgp summary"))
# [{"neighbor": "10.0.0.2", "peer_as": 65001, "state": "Active", ...}, ...]

neighbors = parse_ospf_neighbors(conn.send("show router ospf neighbor"))
# [{"interface": "to-core-1", "router_id": "10.0.0.1", "state": "Full", ...}, ...]

Updated: netops/check/interfaces.py

  • Replaces the # TODO: Nokia parser stub with a real implementation backed by parse_interfaces(); Nokia devices now populate interfaces, summary, and success identically to the Cisco path.
  • Fixes latent KeyError on iface["ip"] in the display loop — Nokia ports carry no ip key, changed to iface.get("ip").
Original prompt

This section details on the original issue you should resolve

<issue_title>feat: Nokia SROS interface/BGP/OSPF parsers</issue_title>
<issue_description>Parse Nokia SR OS CLI output into structured data.

  • show port → interface list with status
  • show router bgp summary → BGP peer table
  • show router ospf neighbor → OSPF adjacency table
  • Consistent output format matching Cisco parsers</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 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.

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
Copilot AI changed the title [WIP] Add Nokia SROS interface, BGP, and OSPF parsers feat: Nokia SR OS interface/BGP/OSPF CLI parsers Mar 24, 2026
Copilot AI requested a review from kayodebristol March 24, 2026 03:17
@kayodebristol kayodebristol marked this pull request as ready for review March 24, 2026 03:25
@kayodebristol kayodebristol requested a review from Copilot March 24, 2026 03:29
Copy link
Copy Markdown
Contributor

@kayodebristol kayodebristol left a comment

Choose a reason for hiding this comment

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

Good implementation. Nokia parsers align well with the Cisco convention. A few suggestions below.

Comment thread netops/parsers/nokia_sros.py
Comment thread netops/parsers/nokia_sros.py
Comment thread tests/test_parsers_nokia.py
…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
Copy link
Copy Markdown
Contributor

@kayodebristol kayodebristol left a comment

Choose a reason for hiding this comment

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

All 3 suggestions applied in c1d6fed and conversations resolved. Nokia parsers look production-ready.

@kayodebristol kayodebristol merged commit 5872d03 into main Mar 24, 2026
10 checks passed
@kayodebristol kayodebristol deleted the copilot/feat-nokia-sros-bgp-ospf-parsers branch March 24, 2026 03:31
Copilot AI requested a review from kayodebristol March 24, 2026 03:32
Copilot stopped work on behalf of kayodebristol due to an error March 24, 2026 03:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.py with parsers for show port, show router bgp summary, and show router ospf neighbor.
  • Added pytest coverage for the Nokia SR OS parsers using representative CLI output fixtures.
  • Updated netops/check/interfaces.py to use the Nokia interface parser and avoid KeyError when an ip field 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.

Comment on lines +5 to +6
import pytest

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
import pytest

Copilot uses AI. Check for mistakes.
# 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
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
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.

feat: Nokia SROS interface/BGP/OSPF parsers

3 participants