Skip to content

feat(device-discovery): vrf discovery for iosxr, iosxr_netconf, nokia_sros, nokia_srl#453

Merged
leoparente merged 6 commits into
developfrom
feat/device-discovery-vrf-drivers-batch1
Jun 11, 2026
Merged

feat(device-discovery): vrf discovery for iosxr, iosxr_netconf, nokia_sros, nokia_srl#453
leoparente merged 6 commits into
developfrom
feat/device-discovery-vrf-drivers-batch1

Conversation

@leoparente

Copy link
Copy Markdown
Contributor

Summary

First custom-driver batch implementing get_network_instances() for VRF discovery (follow-up to #452, which works out of the box on ios/eos/junos/nxos/nxos_ssh via upstream NAPALM). All four return the NAPALM OpenConfig network-instances shape consumed by options.discover_vrfs.

Per driver

Driver Data source Notes
iosxr show vrf all detail via pyIOSXR Parsed driver-locally — the cisco_xr ntc-template FSM gets stuck on VRF blocks without an address family or with import/export route policies attached (routine in production L3VPN), swallowing the next VRF's header and misattributing its interfaces. The line-stateful block parser has no stuck states; both failure modes are pinned by fixtures (missing_af_section, route_policy_attached). RD not set → absent.
iosxr_netconf One subtree-filtered get on Cisco-IOS-XR-mpls-vpn-oper l3vpn/vrfs Same data source the CLI renders; namespace/path verified against the published YANG model. Untrusted replies parse with entity resolution disabled.
nokia_sros One NETCONF get on configure/service/vprn VPRN services map to VRFs; member interfaces keyed <service>/<interface> to match get_interfaces_ip() naming so downstream VRF attachment joins correctly. RD from bgp-ipvpn/mpls. Base router emitted as DEFAULT_INSTANCE.
nokia_srl Three targeted info from state network-instance CLI calls type / interface membership / bgp-vpn RD, parsed by a block-header line parser (nested-block and quoted-name safe). ip-vrf → L3VRF, mac-vrf → L2VSI, default → DEFAULT_INSTANCE; module-prefixed identityrefs tolerated.

Common semantics: default instances carry no interface membership by design (the pipeline only consumes VRF memberships); the NAPALM name filter is honored on every return path including degraded ones; rows named default can never overwrite the seeded DEFAULT_INSTANCE.

Tests

  • Generic shape-validating test_get_network_instances in BaseDriverTest (auto-skips drivers on the base-class stub or without fixtures)
  • 10 fixture scenarios across the four drivers, including the two XR template-failure cases, a default-named-row guard, and empty-device scenarios
  • Driver-pin test extended to the nine supported drivers
  • Full suite: 1742 passed, 174 skipped; ruff clean

Review trail

Codex review (caught SROS interface-key mismatch with get_interfaces_ip() naming + XR default-row overwrite) and two adversarial Claude review rounds (caught the ntc-template stuck-state misattribution — fixed by the driver-local parser — and the name-filter contract gaps on degraded paths). Final round: APPROVED.

🤖 Generated with Claude Code

…_sros, nokia_srl

First custom-driver batch implementing get_network_instances():

- iosxr: "show vrf all detail" via pyIOSXR, parsed with the cisco_xr
  ntc-template; the literal "not set" RD normalizes to empty.
- iosxr_netconf: single subtree-filtered NETCONF get on the
  Cisco-IOS-XR-mpls-vpn-oper l3vpn/vrfs model — the same data source
  the CLI command renders.
- nokia_sros: VPRN services as L3VRFs via one NETCONF get on
  configure/service/vprn (service-name, bgp-ipvpn/mpls
  route-distinguisher, interface list); the Base router is the
  DEFAULT_INSTANCE.
- nokia_srl: three targeted "info from state network-instance" CLI
  calls (type, interface membership, bgp-vpn route distinguisher)
  parsed with a block-header line parser; ip-vrf maps to L3VRF,
  mac-vrf to L2VSI.

All four emit the NAPALM OpenConfig shape consumed by discover_vrfs.
Default-instance interface membership is intentionally left empty —
the discovery pipeline only consumes VRF memberships.

Adds a generic shape-validating test_get_network_instances to
BaseDriverTest (auto-skips drivers without fixtures) with per-driver
scenarios, and extends the runner-dispatch pin test to the nine
supported drivers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
device_discovery
   client.py661085%169–188
   discovery.py76593%102–104, 174–177
   entity_metadata.py13285%24, 27
   interface.py217598%141–145, 491–492
   main.py49296%182, 188
   metrics.py53198%133
   server.py861088%44–46, 72–87, 184, 187
   stubs.py1601094%31, 64, 84, 146, 256, 301, 324–329, 341–346
   translate.py283798%141, 143, 256, 478, 556, 567, 608
   translate_chassis.py175697%42, 45, 54–55, 149, 405
   translate_modules.py107199%217
   version.py7186%14
   vrf.py72396%67–68, 99
device_discovery/policy
   manager.py61395%37–38, 161
   portscan.py841187%34–35, 59–60, 64, 72–76, 117
   run.py88298%158, 193
   runner.py2532391%276–280, 285–286, 303–304, 397, 631, 650–682
TOTAL197410295% 

Tests Skipped Failures Errors Time
1917 174 💤 0 ❌ 0 🔥 11.063s ⏱️

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds VRF discovery support for additional custom NAPALM drivers by implementing get_network_instances() in the OpenConfig “network-instances” shape, plus fixtures and test coverage to validate payload shape and driver support across the runner dispatch path.

Changes:

  • Implement get_network_instances() for iosxr, iosxr_netconf, nokia_sros, and nokia_srl custom drivers.
  • Add/extend tests to validate getter shape, scenarios/fixtures, and pin the supported-driver matrix for VRF discovery dispatch.
  • Add driver-specific mocked device outputs and expected OC-shaped results for multiple scenarios (normal/empty/default-row/template edge cases).

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
device-discovery/tests/test_runner_vrf_dispatch.py Extends the driver pin/matrix test to include the new drivers that implement get_network_instances().
device-discovery/tests/custom_drivers/base_test.py Adds a generic shape-validating (and fixture-comparing) test_get_network_instances to the custom-driver base test suite.
device-discovery/custom_napalm/iosxr.py Implements IOS-XR VRF discovery by parsing show vrf all detail into the NAPALM OC network-instances shape.
device-discovery/custom_napalm/iosxr_netconf.py Implements IOS-XR NETCONF VRF discovery via a subtree-filtered Cisco-IOS-XR-mpls-vpn-oper query and safe XML parsing.
device-discovery/custom_napalm/nokia_sros.py Implements SR-OS VRF discovery via NETCONF configure/service/vprn (VPRN→VRF) parsing into OC shape.
device-discovery/custom_napalm/nokia_srl.py Implements SR Linux network-instance discovery via targeted CLI info from state ... calls and block parsing.
device-discovery/tests/custom_drivers/nokia_sros/mock_data/test_get_network_instances/normal/response.xml Mock NETCONF response for SR-OS VPRN discovery (normal scenario).
device-discovery/tests/custom_drivers/nokia_sros/mock_data/test_get_network_instances/normal/expected_result.json Expected OC-shaped SR-OS network-instances for normal scenario.
device-discovery/tests/custom_drivers/nokia_sros/mock_data/test_get_network_instances/no_vprns/response.xml Mock NETCONF response for SR-OS with no VPRNs.
device-discovery/tests/custom_drivers/nokia_sros/mock_data/test_get_network_instances/no_vprns/expected_result.json Expected OC-shaped SR-OS network-instances when no VPRNs exist.
device-discovery/tests/custom_drivers/nokia_srl/mock_data/test_get_network_instances/normal/info_from_state_network-instance_type.txt Mock SRL type output for network-instance discovery.
device-discovery/tests/custom_drivers/nokia_srl/mock_data/test_get_network_instances/normal/info_from_state_network-instance_interface_name.txt Mock SRL interface membership output for network-instance discovery.
device-discovery/tests/custom_drivers/nokia_srl/mock_data/test_get_network_instances/normal/info_from_state_network-instance_protocols_bgp-vpn_bgp-instance_route-distinguisher_rd.txt Mock SRL RD output for network-instance discovery.
device-discovery/tests/custom_drivers/nokia_srl/mock_data/test_get_network_instances/normal/expected_result.json Expected OC-shaped SRL network-instances for normal scenario.
device-discovery/tests/custom_drivers/nokia_srl/mock_data/test_get_network_instances/empty/expected_result.json Expected OC-shaped SRL network-instances for empty scenario.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/normal/show_vrf_all_detail.txt Mock IOS-XR CLI output for normal VRF parsing scenario.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/normal/expected_result.json Expected OC-shaped IOS-XR network-instances for normal scenario.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/missing_af_section/show_vrf_all_detail.txt Mock IOS-XR CLI output for “missing AF section” edge case.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/missing_af_section/expected_result.json Expected OC-shaped IOS-XR output for “missing AF section” scenario.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/route_policy_attached/show_vrf_all_detail.txt Mock IOS-XR CLI output for “route policy attached” edge case.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/route_policy_attached/expected_result.json Expected OC-shaped IOS-XR output for “route policy attached” scenario.
device-discovery/tests/custom_drivers/iosxr/mock_data/test_get_network_instances/no_vrfs/expected_result.json Expected OC-shaped IOS-XR output when no VRFs exist.
device-discovery/tests/custom_drivers/iosxr_netconf/mock_data/test_get_network_instances/normal/response.xml Mock IOS-XR NETCONF response for normal VRF discovery scenario.
device-discovery/tests/custom_drivers/iosxr_netconf/mock_data/test_get_network_instances/normal/expected_result.json Expected OC-shaped IOS-XR NETCONF output for normal scenario.
device-discovery/tests/custom_drivers/iosxr_netconf/mock_data/test_get_network_instances/no_vrfs/response.xml Mock IOS-XR NETCONF response when no VRFs exist.
device-discovery/tests/custom_drivers/iosxr_netconf/mock_data/test_get_network_instances/no_vrfs/expected_result.json Expected OC-shaped IOS-XR NETCONF output when no VRFs exist.
device-discovery/tests/custom_drivers/iosxr_netconf/mock_data/test_get_network_instances/default_row/response.xml Mock IOS-XR NETCONF response containing a vrf-name=default row.
device-discovery/tests/custom_drivers/iosxr_netconf/mock_data/test_get_network_instances/default_row/expected_result.json Expected OC-shaped IOS-XR NETCONF output ensuring the seeded DEFAULT_INSTANCE isn’t overwritten.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread device-discovery/custom_napalm/iosxr.py
Comment thread device-discovery/custom_napalm/iosxr_netconf.py
Comment thread device-discovery/custom_napalm/nokia_sros.py
…cs in vrf getters

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Comment thread device-discovery/custom_napalm/nokia_sros.py
…e default instance

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Comment thread device-discovery/custom_napalm/nokia_srl.py
@leoparente

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2600d22b2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread device-discovery/tests/test_runner_vrf_dispatch.py Outdated
…; pin getter ownership

The SR Linux getter populated interface membership for the default
network instance, contradicting the batch-wide design where default
instances carry no membership (the pipeline only consumes VRF
memberships). Emit it empty like the other three drivers.

Strengthen the driver-pin test to assert which package owns
get_network_instances (upstream napalm vs custom_napalm) instead of
just "not the base-class stub" — also catches upstream growing its
own NotImplementedError-raising override.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@leoparente leoparente requested a review from Copilot June 11, 2026 00:23
@leoparente

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Comment thread device-discovery/tests/test_runner_vrf_dispatch.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Comment thread device-discovery/custom_napalm/iosxr_netconf.py Outdated
… in iosxr_netconf

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.

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.

4 participants