Bug Fix NXOS#387
Conversation
4864906 to
428cfa6
Compare
428cfa6 to
b4a3f78
Compare
cacc60c to
9b5c676
Compare
498d9d1 to
aa6a1cc
Compare
aa6a1cc to
87fbf1e
Compare
| FileSystemNotFoundError: When the module is unable to determine the default file system. | ||
| """ | ||
| raw_data = self.show("dir", raw_text=True) | ||
| self.open() |
There was a problem hiding this comment.
Why are we calling self.open() in seemingly random places? Is this working around timeouts not being handled correctly?
There was a problem hiding this comment.
Netmiko seems to be handling this fine so I'm going to remove these redundant self.open() calls:
>>> nxos.check_file_exists("system.bin")
2026-05-18 15:34:01,174 [ERROR] paramiko.transport: Socket exception: Connection reset by peer (104)
2026-05-18 15:34:03,854 [INFO] paramiko.transport: Connected (version 2.0, client OpenSSH_6.2)
2026-05-18 15:34:04,476 [INFO] paramiko.transport: Auth banner: b'C\ntest banner\n'
2026-05-18 15:34:04,476 [INFO] paramiko.transport: Authentication (password) successful!
| import unittest | ||
|
|
||
| import mock | ||
| from hypothesis import given |
There was a problem hiding this comment.
In a prior PR I asked that we stick with testing patterns that the team is familiar with. Please remove hypothesis.
gsnider2195
left a comment
There was a problem hiding this comment.
We need to address some feedback before merging this
|
Tested the updated commands against a device in the lab: |
| def test_get_free_space_raises_on_parse_error(self): | ||
| """Test _get_free_space raises CommandError when output can't be parsed.""" | ||
| mock_show.return_value = "Directory of bootflash:/\nNo free space info here\n" | ||
| self.device.native_ssh.send_command.return_value = "Directory of bootflash:/\nNo free space info here\n" |
There was a problem hiding this comment.
"Directory of ..." is an IOS command output but is fine for this test.
|
These are the functions that need to be updated to use Netmiko to support OS Upgrades:
These are all staged locally but need unit tests written. |
- _image_booted - _wait_for_device_reboot - uptime - hostname - redundancy_state - reboot - set_boot_options Removed caching for the uptime and uptime_string properties Added an NXOSDevice.show_netmiko method and added a deprecation warning to the existing NXOSDevice.show method
|
@jtdub this one should be ready for another review |
|
I updated the NXOSDevice.os_version task to use netmiko. |
…yntc into u/mattmiller/nxos_bugfix
987724b to
98acc63
Compare
mattmiller87
left a comment
There was a problem hiding this comment.
Updated changes are approved.
* Bug Fix NXOS (#387) * Fix operations to use native_ssh instead of nx-api * Update NXOS so that both nx-api and ssh can co-exist * Updates to remove api_port * remove redundant line, update tests * changelog * minor tweak to f5 workaround * Updated the following NXOSDevice methods to use netmiko: - _image_booted - _wait_for_device_reboot - uptime - hostname - redundancy_state - reboot - set_boot_options Removed caching for the uptime and uptime_string properties Added an NXOSDevice.show_netmiko method and added a deprecation warning to the existing NXOSDevice.show method * added test mocks for most of the netmiko commands and updated tests * revert breaking property changes and fix pylint * revert breaking changes * Updated the NXOSDevice driver to use netmiko for the os_version * updated the nxos file transfer methods to resolve file verification * ruff ruff * add changelog fragments * update the NXOSDevice.save to use netmiko instead of NXAPI * Migrate NXOSDevice.show to netmiko from NXAPI * update _wait_for_device_reboot to reconnect via ssh * updates per CI failures * updates per CI failures --------- Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Co-authored-by: James Williams <amascuba@gmail.com> * v3.0.0 post sync to develop (#385) * Release 3.0.0 * bump version --------- Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com> Co-authored-by: James Williams <amascuba@gmail.com> * bump version * create release notes * fix v3 release notes * fix v3 release notes --------- Co-authored-by: Matt Miller <mattmiller87@gmail.com> Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com>
* Release 3.0.0 * Release v3.0.1 (#391) * Bug Fix NXOS (#387) * Fix operations to use native_ssh instead of nx-api * Update NXOS so that both nx-api and ssh can co-exist * Updates to remove api_port * remove redundant line, update tests * changelog * minor tweak to f5 workaround * Updated the following NXOSDevice methods to use netmiko: - _image_booted - _wait_for_device_reboot - uptime - hostname - redundancy_state - reboot - set_boot_options Removed caching for the uptime and uptime_string properties Added an NXOSDevice.show_netmiko method and added a deprecation warning to the existing NXOSDevice.show method * added test mocks for most of the netmiko commands and updated tests * revert breaking property changes and fix pylint * revert breaking changes * Updated the NXOSDevice driver to use netmiko for the os_version * updated the nxos file transfer methods to resolve file verification * ruff ruff * add changelog fragments * update the NXOSDevice.save to use netmiko instead of NXAPI * Migrate NXOSDevice.show to netmiko from NXAPI * update _wait_for_device_reboot to reconnect via ssh * updates per CI failures * updates per CI failures --------- Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Co-authored-by: James Williams <amascuba@gmail.com> * v3.0.0 post sync to develop (#385) * Release 3.0.0 * bump version --------- Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com> Co-authored-by: James Williams <amascuba@gmail.com> * bump version * create release notes * fix v3 release notes * fix v3 release notes --------- Co-authored-by: Matt Miller <mattmiller87@gmail.com> Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com> * bump version --------- Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Co-authored-by: Jeff Kala <48843785+jeffkala@users.noreply.github.com> Co-authored-by: Matt Miller <mattmiller87@gmail.com>
New Pull Request
I am solving three bugs when running
nxos_device.py:nativeinstead ofnative_sshChange Notes
Fixed
_build_url_copy_command_simpleto return a string.Fixed
_get_file_systemand_get_free_spaceto use native_ssh; initial intent when created.Fixed the
remote_file_copyprompts to detect needing to enter a vrf if one isn't provided.Justification
The copy command return from
_build_url_copy_command_simpleshould not be a tuple.remote_file_copymethod is using native_ssh and _get_file_systemand_get_free_spaceshould be using it too.remote_file_copy` may return a prompt we were not catching previously.Note: unittest changes were written with AI