Fix napalm_rpc_map override, netmiko error, and napalm_formula arg bugs#69797
Open
ggiesen wants to merge 2 commits into
Open
Fix napalm_rpc_map override, netmiko error, and napalm_formula arg bugs#69797ggiesen wants to merge 2 commits into
ggiesen wants to merge 2 commits into
Conversation
napalm_mod:
- rpc: napalm_map = config.get(...); napalm_map.update(default_map) let the
built-in defaults clobber the user's napalm_rpc_map override (and mutated the
config object). Start from the defaults and layer the user map on top.
- netmiko_args: netmiko_device_type_map[__grains__["os"]] raised a raw KeyError
for an os not in the map (community/custom drivers). Raise a clear
CommandExecutionError naming the driver and the config option instead.
napalm_formula:
- container_path ignored its key/container/delim arguments (called
_container_path(model) with defaults), so e.g. delim='//' was silently
dropped. Forward them.
- render_field read __grains__["os"] directly, raising KeyError when the os
grain is absent. Use __grains__.get("os").
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Fixes four bugs in the
napalm_modandnapalm_formulaexecution modules.napalm_mod:rpcignores the user'snapalm_rpc_map. It didnapalm_map = config.get("napalm_rpc_map", {})thennapalm_map.update(default_map), so the built-in defaults clobbered theuser's override (and, since
config.getcan return a live reference, thedefaults were written back into the user's pillar). An operator setting
napalm_rpc_map: {junos: napalm.netmiko_commands}to force CLI RPC on a Junosbox had it silently ignored. Now the defaults are the base and the user map is
layered on top, without mutating the config object.
netmiko_argsraises a rawKeyErrorwhen the NAPALMosgrain isn't inthe (built-in + user)
netmiko_device_type_map-- e.g. a community/customdriver with no mapping. Now it raises a clear
CommandExecutionErrornamingthe driver and pointing at
netmiko_device_type_map.napalm_formula:3.
container_pathdrops itskey/container/delimarguments -- it called_container_path(model)with defaults, socontainer_path(model, delim='//')(the documented way to avoid
:clashing with IPv6 addresses / Junos QFXinterface names) was silently ignored. Now they're passed through.
4.
render_fieldreads__grains__['os']unguarded, raisingKeyErrorwhenthe
osgrain isn't populated. Now__grains__.get('os').What issues does this PR fix or reference?
Found by an audit of the NAPALM modules (same series as #69793 / #69794 /
#69795 / #69796).
Merge requirements satisfied?
test_rpc_user_map_overrides_default,test_netmiko_args_unknown_os_raises_clean_error(in
test_mod.py),test_container_path_uses_delim,test_render_field_no_os_grain(in
test_formula.py). All fail against the current code.Commits signed with GPG?
No