Skip to content

[IOS-XR] Fix show vrf all detail parser - capture all interface names#911

Open
Kani999 wants to merge 3 commits intoCiscoTestAutomation:mainfrom
Kani999:fix_interfaces_iosxr_show_vrf_all_detail
Open

[IOS-XR] Fix show vrf all detail parser - capture all interface names#911
Kani999 wants to merge 3 commits intoCiscoTestAutomation:mainfrom
Kani999:fix_interfaces_iosxr_show_vrf_all_detail

Conversation

@Kani999
Copy link
Copy Markdown
Contributor

@Kani999 Kani999 commented Nov 8, 2024

Description

Enhance interface parsing in 'show vrf all detail' parser

Implemented a general regex pattern to capture all interface names:

  • Replaced the previous regex that relied on specific interface prefixes (e.g., Gi, Bun, Ten, etc.) with a more general pattern r'^(?P<intf>[A-Za-z][-A-Za-z0-9/.:]+)$'.
    • This allows the parser to match any interface name, accommodating various naming conventions and ensuring that all interfaces are properly captured.
  • Introduced in_interfaces_section flag for accurate section tracking:
    • Initialized in_interfaces_section = False at the beginning of the parsing process.
    • Set in_interfaces_section = True upon encountering the Interfaces: line.
    • Used this flag to determine when interface lines should be parsed.
    • When a non-interface line is encountered within the Interfaces section, set in_interfaces_section = False
    • This ensures that the parser continues to process the current line with other parsing rules, preventing the omission of critical sections like address families and route targets.

Motivation and Context

Replaced the previous regex that relied on specific interface prefixes (e.g., Gi, Bun, Ten, etc.) with a more general pattern

Checklist:

  • I have updated the changelog.
  • I have updated the documentation (If applicable).
  • I have added tests to cover my changes (If applicable).
  • All new and existing tests passed.
  • All new code passed compilation.

Closes #910

@Kani999 Kani999 requested a review from a team as a code owner November 8, 2024 09:48
@Kani999 Kani999 requested review from domachad and omehrabi November 8, 2024 09:48
@Kani999

This comment was marked as resolved.

@Kani999 Kani999 force-pushed the fix_interfaces_iosxr_show_vrf_all_detail branch from 63f819c to db62997 Compare December 2, 2024 12:37
@Kani999
Copy link
Copy Markdown
Contributor Author

Kani999 commented May 26, 2025

Hi there! 👋
If anyone revisits this PR in the future:
Thank you for taking the time to look at this contribution. If you have any questions about the changes, need further clarification, or would like additional context, please feel free to tag me @Kani999. I appreciate your review and feedback!

Best regards,
Kani999

@Kani999 Kani999 force-pushed the fix_interfaces_iosxr_show_vrf_all_detail branch from db62997 to ac9dcda Compare January 20, 2026 11:55
@Kani999
Copy link
Copy Markdown
Contributor Author

Kani999 commented Jan 20, 2026

Hi team,

This PR (#911) has been open since recently, but I'm still waiting for accept or deny decision. Any update on review?

I'd appreciate your feedback!

Thanks

Kani999 added 3 commits March 26, 2026 14:49
- Implemented a general regex pattern to capture all interface names
    - Replaced the previous regex that relied on specific interface prefixes (e.g., Gi, Bun, Ten, etc.) with a more general pattern `r'^(?P<intf>[A-Za-z][-A-Za-z0-9/.:]+)$'`
- Introduced `in_interfaces_section` flag for accurate section tracking
@Kani999
Copy link
Copy Markdown
Contributor Author

Kani999 commented Mar 27, 2026

Verified: current genie/main still fails — this PR is needed

Tested against genie/main at commit 285024fb050cdbe54ee5c8490df5068661a41061 (release v26.2).

What was tested

A comprehensive golden output test (golden_output_5) with 31 interface names covering various IOS-XR naming conventions was run against the unmodified main branch parser using an isolated venv.

Results

  • Existing tests (golden_output_1–4): all PASS on main ✅
  • New test (golden_output_5): FAILS on main ❌ — 11 out of 31 interface names are silently dropped

The v26.2 release expanded the regex to include more prefixes (HundredGigE, FortyGigE, FiftyGigE, etc.), but the allowlist approach still misses:

Still missing Description
Te0/0/0/0.3 TenGigE short form
Fo0/0/0/0.3 FortyGigE short form
Hu0/0/0/0.3 HundredGigE short form
BE2 Bundle-Ether short form
Nu1 Null short form
Null0 Null interface
FortyGigabitEthernet0/0/0/0.2 FortyGigabitEthernet long form
HundredGigabitEthernet0/0/0/0.2 HundredGigabitEthernet long form
ManagementEthernet1/RP0/CPU0/0 ManagementEthernet long form
POS0/0/0/0 Packet over SONET
PacketOverSonet0/0/0/1 PacketOverSonet long form

Why the allowlist approach keeps breaking

Every time Cisco adds a new interface type or users encounter a different abbreviation, the regex needs to be manually extended. This PR replaces it with a generic pattern ([A-Za-z][-A-Za-z0-9/.:]+) guarded by the in_interfaces_section state flag, which is future-proof.

PR checklist status

  • make json — no changes needed (parser registration unchanged)
  • ✅ Changelog entry at genieparser/changelog/undistributed/changelog_show_vrf_all_detail_iosxr_20241108103720.rst
  • ✅ All 6 tests pass on this branch (golden_output_1–5 + empty)
  • ✅ Existing tests still pass (no regressions)

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.

[IOS-XR] show vrf all detail parser - Interfaces list not captured

1 participant