Repository navigation
[master] Avoid use of deprecated net-tools and add support for ip neighbour - #64351
Merged
Merged
Conversation
s0undt3ch
suggested changes
Jun 6, 2023
s0undt3ch
previously approved these changes
Jun 6, 2023
twangboy
previously approved these changes
Jun 6, 2023
Ch3LL
suggested changes
Jun 6, 2023
Ch3LL
previously approved these changes
Jun 6, 2023
Co-authored-by: Megan Wilhite <[email protected]>
Co-authored-by: Megan Wilhite <[email protected]>
dmurphy18
force-pushed
the
net-tools-upd-57541
branch
from
June 7, 2023 21:19
bfb1d12 to
9d9226d
Compare
Ch3LL
approved these changes
Jun 9, 2023
dwoz
pushed a commit
that referenced
this pull request
Jul 3, 2026
) (#69621) * network.arp: fall back to ip neigh when net-tools is absent network.arp() was guarded by @salt.utils.decorators.path.which("arp"), which raises CommandNotFoundError when the net-tools arp command is not installed. net-tools is deprecated (since 2011) and absent by default on modern distributions, so network.arp broke on those systems with no fallback. PR #64351 migrated network.netstat/network.routes to iproute2 with a which()-based fallback (ss / ip route) and added network.ip_neighs, but left the public network.arp() on net-tools. This completes that work: on Linux, when the arp command is unavailable, arp() now dispatches to ip_neighs() (ip neigh show), which returns the same {mac: ip} mapping. Non-Linux kernels (SunOS/OpenBSD/AIX) keep using their native arp command, mirroring how network.netstat() is structured. Refs #57541, #64351. Validated on AlmaLinux 8, 9 and 10: net-tools is absent by default, and network.arp returns the neighbour table via the ip neigh fallback. * Patch loader dunders in legacy test_arp for the ip neigh fallback network.arp now checks __grains__["kernel"] and __utils__["path.which"] before choosing between arp -an and ip neigh. The legacy unittest still patched the module-level salt.utils.path.which (only used by the old decorator) and left the grains dict empty, so arp() raised KeyError: 'kernel'. Patch the dunders the code actually reads, pinning the test to the net-tools branch it was written for. * Migrate legacy unit/modules/test_network.py into the pytest suite Every test in tests/unit/modules/test_network.py already has a same-named twin in tests/pytests/unit/modules/test_network.py with identical mocks, inputs, and expected values, under equivalent loader wiring. Keeping both copies means fixes only land in one, which is exactly how test_arp broke on this branch: arp() gained the ip neigh fallback and only the pytest copy was updated. The one gap was test___virtual__is_windows_false, whose pytest twin had been weakened from assertEqual(result, True) to a bare truthiness assert that would also pass for the (False, reason) failure tuple. Restore the strict check and remove the legacy file, leaving a single canonical home for these tests.
This branch was previously deployed
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?
Avoids use of deprecated net-tools and add support for ip neighbour with IPv4 ip_neighs and IPv6 ip_neighs6, similar to ip_addrs and ip_addrs6
What issues does this PR fix or reference?
Fixes: #57541
New Behavior
Added support for ip neighbour with IPv4 ip_neighs and IPv6 ip_neighs6, and ensured that deprecated net-tools are no longer used when possible.
Also ported unittests to pytests and added tests for ip_neighs and ip_neighs6.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.