IOSXR ShowPlatform: tolerate missing config_state; relax <plim> spacing #956
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
By relaxing whitespace before
<plim>and making<config_state>optional, the parser now:Impact (If any)
Negative impact: None expected.
Screenshots
Reproducer (raw device output)
Problem (before)
The parser skipped subslot entries that omit the Config state column, e.g.:
0/0/1 A9903-20HG-PEC OKAs 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