Skip to content

feat(device-discovery): vrf discovery for huawei_vrp, hp_comware, cumulus_linux, dell_sonic#454

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

feat(device-discovery): vrf discovery for huawei_vrp, hp_comware, cumulus_linux, dell_sonic#454
leoparente merged 2 commits into
developfrom
feat/device-discovery-vrf-drivers-batch2

Conversation

@leoparente

Copy link
Copy Markdown
Contributor

Summary

Second custom-driver batch implementing get_network_instances() for VRF discovery (follows #452 / #453). All four return the NAPALM OpenConfig network-instances shape consumed by options.discover_vrfs.

Per driver

Driver Data source Notes
huawei_vrp display ip vpn-instance interface (ntc-template) + summary RDs parsed driver-locally — the summary ntc-template requires an RD on every row and error-exits on RD-less instances. The AF column prints ipv4-family on some releases and plain IPv4/IPv6 on others (the ntc real-device fixture uses the latter); both anchor the row, and per-AF rows merge keeping the first non-empty RD.
hp_comware display ip vpn-instance (ntc-template) + per-instance detail Detail parsed driver-locally — the detail ntc-template error-exits on routine lines it doesn't enumerate (e.g. "Route & Tunnel selection time"). Wrapped, multi-member-per-line interface lists handled.
cumulus_linux ip vrf show (linux ntc-template) + per-VRF ip link show master Kernel @parent decorations stripped to match get_interfaces() naming. Linux VRFs carry no kernel-level RD (it lives in FRR BGP) — always emitted absent.
dell_sonic show vrf, driver-local parse Routed through the file's CLI-error-banner guard so an unsupported command can't become a junk VRF; continuation rows, comma-separated member cells, and a VRF literally named Vrf all handled. mgmt is kept as a real VRF.

Common semantics (matching batches 1): seeded DEFAULT_INSTANCE with empty membership, rows named default can never overwrite the seed, NAPALM name filter honored on every path, member names match each driver's own get_interfaces()/get_interfaces_ip() naming so VRF→IP attachment joins correctly.

Also documents get_network_instances in the custom-driver guide (custom_napalm/CLAUDE.md): output shape, the six batch conventions, and a validation-checklist entry.

Tests

  • 11 fixture scenarios across the four drivers, including the real-device output variants that broke earlier parser drafts (huawei IPv4 AF column, SONiC error banner, comware multi-member wrap)
  • Driver ownership pin matrix extended to 13 drivers
  • Full suite: 1758 passed, 170 skipped; ruff clean

Review trail

Two adversarial Claude review rounds: round 1 found two verified majors (huawei RD regex missing the plain-IPv4 AF column form seen in ntc-templates' own real-device fixture; SONiC error banner ingested as a VRF named %) plus two minors — all fixed with pinning fixtures; round 2: APPROVED.

🤖 Generated with Claude Code

leoparente and others added 2 commits June 11, 2026 10:00
…ulus_linux, dell_sonic

Second custom-driver batch implementing get_network_instances():

- huawei_vrp: names and member interfaces from "display ip
  vpn-instance interface" (ntc-template); route distinguishers from a
  driver-local scan of the summary — the summary ntc-template requires
  an RD on every row and error-exits on instances without one.
- hp_comware: instances from "display ip vpn-instance" (ntc-template,
  tolerates RD-less rows); RD and member interfaces from one
  "display ip vpn-instance instance-name <name>" per instance, parsed
  driver-locally — the detail ntc-template error-exits on routine
  output lines it doesn't enumerate.
- cumulus_linux: VRF devices from "ip vrf show" (linux ntc-template);
  members from one "ip link show master <vrf>" per VRF with kernel
  @parent decorations stripped to match get_interfaces() naming. Linux
  VRFs carry no kernel-level RD.
- dell_sonic: driver-local parse of "show vrf" (continuation rows and
  comma-separated member cells tolerated); the mgmt VRF is kept as a
  real VRF. SONiC's show vrf carries no RD.

All four emit the NAPALM OpenConfig shape, seed a DEFAULT_INSTANCE with
empty membership, honor the name filter, and guard rows named
"default" from overwriting the seeded entry. Eight fixture scenarios
plus the driver-pin matrix extended to thirteen drivers.

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

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

github-actions Bot commented Jun 11, 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.py881089%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
TOTAL198810295% 

Tests Skipped Failures Errors Time
1928 170 💤 0 ❌ 0 🔥 18.988s ⏱️

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

Implements VRF discovery for four additional custom NAPALM drivers by adding get_network_instances() implementations that return the OpenConfig network-instances shape consumed by options.discover_vrfs, along with fixtures, dispatch-matrix pinning, and contributor documentation updates.

Changes:

  • Add get_network_instances() to huawei_vrp, hp_comware, cumulus_linux, and dell_sonic custom drivers with platform-specific parsing/guarding.
  • Extend VRF-dispatch ownership pin matrix to include the four new drivers.
  • Add/extend test_get_network_instances fixture scenarios for the four drivers and document the expected getter shape + conventions in custom_napalm/CLAUDE.md.

Reviewed changes

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

Show a summary per file
File Description
device-discovery/tests/test_runner_vrf_dispatch.py Pins VRF discovery support matrix to include the four added custom drivers.
device-discovery/custom_napalm/huawei_vrp.py Adds VRP VPN-instance → OC network-instances VRF discovery (summary RD regex + interface membership via ntc-template).
device-discovery/custom_napalm/hp_comware.py Adds Comware VPN-instance → OC network-instances VRF discovery (detail parsed driver-locally for RD + interfaces).
device-discovery/custom_napalm/cumulus_linux.py Adds Linux VRF device → OC network-instances discovery via ip vrf show + ip link show master.
device-discovery/custom_napalm/dell_sonic.py Adds SONiC VRF discovery via show vrf, including CLI error-banner guarding and continuation-row parsing.
device-discovery/custom_napalm/CLAUDE.md Documents get_network_instances() output shape, conventions, and validation checklist updates.
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/normal/expected_result.json Adds VRP normal-case expected get_network_instances() payload.
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/normal/display_ip_vpn-instance.txt Adds VRP summary command fixture (normal scenario).
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/normal/display_ip_vpn-instance_interface.txt Adds VRP interface-membership command fixture (normal scenario).
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/no_instances/expected_result.json Adds VRP empty/no-instances expected payload.
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/af_column_variant/expected_result.json Adds VRP AF-column variant expected payload.
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/af_column_variant/display_ip_vpn-instance.txt Adds VRP AF-column variant summary fixture.
device-discovery/tests/custom_drivers/huawei_vrp/mock_data/test_get_network_instances/af_column_variant/display_ip_vpn-instance_interface.txt Adds VRP AF-column variant interface-membership fixture.
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/normal/expected_result.json Adds Comware normal-case expected payload.
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/normal/display_ip_vpn-instance.txt Adds Comware summary fixture (normal scenario).
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/normal/display_ip_vpn-instance_instance-name_cust-a.txt Adds Comware per-instance detail fixture (cust-a).
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/normal/display_ip_vpn-instance_instance-name_mgmt-vpn.txt Adds Comware per-instance detail fixture (mgmt-vpn).
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/no_instances/expected_result.json Adds Comware empty/no-instances expected payload.
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/multi_member_wrap/expected_result.json Adds Comware wrapped multi-member list expected payload.
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/multi_member_wrap/display_ip_vpn-instance.txt Adds Comware summary fixture (wrap scenario).
device-discovery/tests/custom_drivers/hp_comware/mock_data/test_get_network_instances/multi_member_wrap/display_ip_vpn-instance_instance-name_wrap-vpn.txt Adds Comware per-instance wrapped interface-list detail fixture.
device-discovery/tests/custom_drivers/cumulus_linux/mock_data/test_get_network_instances/normal/expected_result.json Adds Cumulus normal-case expected payload.
device-discovery/tests/custom_drivers/cumulus_linux/mock_data/test_get_network_instances/normal/ip_vrf_show.txt Adds ip vrf show fixture.
device-discovery/tests/custom_drivers/cumulus_linux/mock_data/test_get_network_instances/normal/ip_link_show_master_red.txt Adds ip link show master red fixture.
device-discovery/tests/custom_drivers/cumulus_linux/mock_data/test_get_network_instances/normal/ip_link_show_master_mgmt.txt Adds ip link show master mgmt fixture.
device-discovery/tests/custom_drivers/cumulus_linux/mock_data/test_get_network_instances/no_vrfs/expected_result.json Adds Cumulus empty/no-VRFs expected payload.
device-discovery/tests/custom_drivers/dell_sonic/mock_data/test_get_network_instances/normal/expected_result.json Adds SONiC normal-case expected payload.
device-discovery/tests/custom_drivers/dell_sonic/mock_data/test_get_network_instances/normal/show_vrf.txt Adds SONiC show vrf fixture (normal scenario).
device-discovery/tests/custom_drivers/dell_sonic/mock_data/test_get_network_instances/no_vrfs/expected_result.json Adds SONiC empty/no-VRFs expected payload.
device-discovery/tests/custom_drivers/dell_sonic/mock_data/test_get_network_instances/unsupported_command/expected_result.json Adds SONiC unsupported-command expected payload (guard behavior).
device-discovery/tests/custom_drivers/dell_sonic/mock_data/test_get_network_instances/unsupported_command/show_vrf.txt Adds SONiC unsupported show vrf error-banner fixture.

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

@leoparente leoparente merged commit d3973f0 into develop Jun 11, 2026
10 checks passed
@leoparente leoparente deleted the feat/device-discovery-vrf-drivers-batch2 branch June 11, 2026 13:53
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.

3 participants