Skip to content

Conversation

@bleuzkernel
Copy link
Contributor

Description

This PR fixes the IOSXR ShowPlatform parser to correctly handle lines where the Config state column is absent and to accept variable spacing before the PLIM field.

Motivation and Context

Some IOS XR platforms (e.g., ASR 9903) produce show platform output lines without the Config state column for certain nodes/modules. Example line that previously failed to match and was skipped:

0/0/1             A9903-20HG-PEC             OK

By relaxing whitespace before <plim> and making <config_state> optional, the parser now:

  • Correctly parses such lines instead of skipping them.
  • Remains backward compatible with outputs that include config state.
  • This improves robustness across XR releases and hardware variants, preventing partial/incomplete parse results.

Impact (If any)

Negative impact: None expected.

  • No schema changes.
  • Existing outputs continue to parse identically.
  • Expanded matching is limited to valid whitespace and optional tail field; risk of false positives is minimal.

Screenshots

Reproducer (raw device output)

RP/0/RP0/CPU0:Router#show platform
Thu Sep 11 10:42:18.531 GMT+6
Node              Type                       State             Config state
--------------------------------------------------------------------------------
0/RP0/CPU0        A99-RP-F(Active)           IOS XR RUN        NSHUT
0/RP1/CPU0        A99-RP-F(Standby)          IOS XR RUN        NSHUT
0/FT0             ASR-9903-FAN               OPERATIONAL       NSHUT
0/FT1             ASR-9903-FAN               OPERATIONAL       NSHUT
0/FT2             ASR-9903-FAN               OPERATIONAL       NSHUT
0/FT3             ASR-9903-FAN               OPERATIONAL       NSHUT
0/0/CPU0          ASR-9903-LC                IOS XR RUN        NSHUT
0/0/1             A9903-20HG-PEC             OK
0/PT0             ASR-9900-DC-PEM            OPERATIONAL       NSHUT

Problem (before)

The parser skipped subslot entries that omit the Config state column, e.g.:

0/0/1 A9903-20HG-PEC OK

As a result, subslot cards were absent from the parsed structure (even in golden_output9_output.txt).

Before (parsed output excerpt):

{
  "lc": {
    "0/0": {
      "name": "ASR-9903-LC",
      "full_slot": "0/0/CPU0",
      "state": "IOS XR RUN",
      "config_state": "NSHUT"
    }
  }
}

Fix

Relax whitespace before <plim> from a single space to \s+.
Make <config_state> optional to accommodate lines without that column.
This enables parsing of subslot lines like 0/0/1 ... OK.

Result (after)

After (parsed output excerpt):

{
  "lc": {
    "0/0": {
      "name": "ASR-9903-LC",
      "full_slot": "0/0/CPU0",
      "state": "IOS XR RUN",
      "config_state": "NSHUT",
      "subslot": {
        "1": {
          "name": "A9903-20HG-PEC",
          "state": "OK",
          "config_state": null,
          "redundancy_state": null
        }
      }
    }
  }
}

Tests

Existing golden outputs remain valid.

Added golden_output10* to cover the missing config state subslot case shown above.

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.

@bleuzkernel bleuzkernel requested a review from a team as a code owner September 11, 2025 20:00
Update regex <p1> to handle IOS XR show platform lines without a "Config state" column and with variable spacing before the PLIM field.

Changes:
- Replace single-space before <plim> with \s+ to accept variable whitespace.
- Make <config_state> optional: (?:\s+(?P<config_state>[a-zA-Z,]+))?$

Fixes parsing for outputs like:
  0/0/1             A9903-20HG-PEC             OK

No schema changes; backward compatible with existing outputs.
@omehrabi omehrabi merged commit 7d8175a into CiscoTestAutomation:main Sep 22, 2025
5 checks passed
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