Fix/ clean junos data with keyerror problem 903 #997
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.
Related Issue
Fixes #903
Description
Fix KeyError when parsing Junos device data. The
_clean_junos_datafunction was failing whenbootupTimestampkey was missing from the device output, which occurs on certain Junos EX devices with different JSON output structures.Type of change
New Behavior
Junos device data is now parsed correctly even when
bootupTimestampis missing from the output. The parser handles different JSON structures across various Junos versions and device types.Contrast to Current Behavior
Previously, the parser threw a KeyError exception when processing Junos devices (such as EX9208 with Junos 14.2R8.4) that return a different JSON structure for
show system uptimeoutput.Discussion: Benefits and Drawbacks
Changes to the Documentation
None required.
Proposed Release Note Entry
Fix KeyError when parsing Junos device data with missing bootupTimestamp (#903)
Comments
The issue was caused by different Junos devices returning different JSON structures for the
show system uptimecommand. Some devices usesystem-uptime-informationdirectly, while others wrap it inmulti-routing-engine-results.Changes include:
config/device: Modified the junos-ex device logic to match different versionspoller/node: The parsing logic was relaxedDouble Check
developbranch.developbranch.--signoffapplied