Update NXOS response processing for more informative error messaging #1461
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.
This PR addresses improvements that can be made to how
nxapi_plumbing
processes JSON-RPC responses. The issue stems from different behavior in JSON-RPC vs XML responses, specifically return codes. JSON-RPC returns a 500 for an erroneous command, whereas XML returns a 200.JSON
XML
This means that erroneous commands using JSON-RPC will always raise
NXAPIPostError
with a generic error message including all commands with no indication of the underlying issue.napalm/napalm/nxapi_plumbing/api_client.py
Lines 81 to 87 in d72e194
If we move non-200 response raising to
XMLClient
's_process_api_response
, erroneous JSON-RPC requests will be returned and passed to_error_check
, which will give better insight into what the problematic command was and information on the issue.In order to test this I had to make a few changes to plumb exposure of the status code.
Also, while going through the NXOS tests I noticed that we weren't raising when mocked_data included exception directives, so things like
napalm/test/nxos/mocked_data/test_get_interfaces_ip/no_ipv6_support/show_ipv6_interface.json
Lines 1 to 3 in d72e194