Fix NTP/SNMP/probe config on NAPALM proxy minions (bare-name templates)#69793
Open
ggiesen wants to merge 4 commits into
Open
Fix NTP/SNMP/probe config on NAPALM proxy minions (bare-name templates)#69793ggiesen wants to merge 4 commits into
ggiesen wants to merge 4 commits into
Conversation
napalm_ntp (set_peers/set_servers/delete_peers/delete_servers), napalm_snmp (update_config/remove_config) and napalm_probes (set_probes/delete_probes/ schedule_probes) all call net.load_template with a bare template name (e.g. "set_ntp_peers"). net.load_template used to route bare names into NAPALM's own renderer, but that path was removed in the Sodium release (saltstack#57370) -- whose own deprecation warning explicitly told netntp/netsnmp/netusers users to ignore it. The bare name now falls through to the fileserver as "Local file source set_ntp_peers does not exist", so every one of these functions fails. Lift the resolver introduced for users in saltstack#62170 into a shared salt.utils.napalm.template_path (walks the driver class MRO + inspect.getfile, catching TypeError/OSError, returns None when the driver ships no such template) plus salt.utils.napalm.template_not_available (standard failure payload). The three modules resolve the driver's NAPALM-shipped template to an absolute path and render it through the Salt pipeline, or return the clear failure message. template_not_available also closes the per-call connection a non-always-alive proxy/minion opened, since it short-circuits net.load_template (which would otherwise close it). napalm_users is intentionally left to saltstack#62170; a follow-up dedups its local resolver onto the shared one. Validated on a live Juniper EX3400 (Junos 23.4R2): ntp.set_servers renders, commits, is confirmed in the device config, and is removed again. (NAPALM's junos snmp/probes templates still use py2 dict.iteritems() and need modernizing upstream in NAPALM; the NTP templates are py3-clean.) New tests/pytests/unit/utils/test_napalm.py covers the resolver (MRO concrete-over-base precedence, base fall-through, OSError/TypeError skip, missing -> None) and the close behaviour; test_ntp/test_snmp are rewritten and test_probes added with routing tests asserting the correct template name, the resolved path, forwarded flags, and inherit_napalm_device identity.
Contributor
Author
|
Filed the upstream NAPALM template fix referenced above: napalm-automation/napalm#2326. It replaces the Python-2 |
3 tasks
This was referenced Jul 12, 2026
napalm_probes.set_probes/delete_probes/schedule_probes now resolve the driver's template and no longer return result=True for the bare-name mock, so the legacy unittest-style tests (which asserted the pre-fix behaviour) fail. They are superseded by tests/pytests/unit/modules/napalm/test_probes.py added here, which covers config/results plus the routing and no-template paths.
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?
Restores NTP / SNMP / RPM-probe configuration on NAPALM (proxy) minions, broken
the same way #62170 broke user management.
napalm_ntp(set_peers,set_servers,delete_peers,delete_servers),napalm_snmp(update_config,remove_config) andnapalm_probes(
set_probes,delete_probes,schedule_probes) all callnet.load_templatewith a bare template name (e.g.
"set_ntp_peers").net.load_templateusedto route bare names into NAPALM's own renderer, but that path was removed in the
Sodium release (#57370) -- whose own deprecation warning explicitly said
netntp/netsnmp/netusersusers could ignore it. The bare name now fallsthrough to the fileserver as
Local file source set_ntp_peers does not exist,so every one of these config functions (and the
netntp/netsnmpstates on topof them) fails.
This lifts the resolver introduced for users in #62170 into a shared
salt.utils.napalm.template_path, which resolves the driver's NAPALM-shippedtemplate (
set_ntp_peers.j2etc., searched along the driver class MRO) to anabsolute path so the still-supported Salt rendering pipeline renders it. The
three modules pass that absolute path to
net.load_template, or return a clearsalt.utils.napalm.template_not_availablemessage when the driver ships no suchtemplate.
What issues does this PR fix or reference?
Same root cause as #62170 (which fixes the
netusershalf).napalm_usersisintentionally left to #62170 here; once both land, a follow-up dedups its local
resolver onto the shared one.
Validation on real hardware
Reproduced the failure, then validated against a live Juniper EX3400
(Junos 23.4R2) over NETCONF driving a real
napalm/junosproxy (onedir3006.x):
ntp.set_servers 192.0.2.10 test=True-> before:Local file source set_ntp_servers does not exist; after: a proper diff (+ server 192.0.2.10;).Committed for real, confirmed present in
show configuration system ntp, thenremoved again with
ntp.delete_servers.Known limitation (upstream NAPALM, not this PR)
NAPALM's junos
snmp_config.j2/delete_snmp_config.j2/set_probes.j2/delete_probes.j2templates still use Python-2dict.iteritems(), so they donot render under Python 3 regardless of how they are reached -- these functions
route correctly now but need NAPALM to modernize those templates upstream (I can
follow up in the NAPALM repo). The NTP templates and
schedule_probes.j2arepy3-clean, which is why NTP works end to end above. Fixing the Salt-side routing
is still correct and necessary: it turns a misleading "file source does not
exist" error into an honest render path.
Merge requirements satisfied?
New
tests/pytests/unit/utils/test_napalm.pycovers the shared resolver (MROfall-through to a base-class template,
object-> exception skip, missing ->None, and the failure-dict shape).test_ntp.py/test_snmp.pyare rewrittenand
test_probes.pyadded with real routing tests: each of the 9 functions isasserted to request the correct template name, pass the resolved absolute
path (not the bare name), forward
test/commit/inherit_napalm_device, andreturn a clear error when the driver ships no template. All fail against the
current code; the resolver and routing tests are mutation-checked (a set/delete
name swap or a collapsed MRO walk makes them fail).
Commits signed with GPG?
No