Add EOS free-space pre-flight check (NAPPS-1091)#370
Open
jtdub wants to merge 3 commits intonetworktocode:developfrom
Open
Add EOS free-space pre-flight check (NAPPS-1091)#370jtdub wants to merge 3 commits intonetworktocode:developfrom
jtdub wants to merge 3 commits intonetworktocode:developfrom
Conversation
EOS file_copy and remote_file_copy now verify the target filesystem has enough free space before starting a transfer. BaseDevice gains an overridable _get_free_space hook and a concrete _check_free_space helper so IOS, NXOS, JUNOS, and ASA tickets can wire in platform-specific probes without further base-class changes. FileCopyModel gains a required file_size field with an optional file_size_unit (bytes/megabytes/gigabytes) that is converted internally to file_size_bytes for the comparison, mirroring how callers already supply the checksum. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
I am of the opinion that the file size is a required piece of information to add this feature. It is similar to file checksum as a required field. To do the copy, you need to know certain things about the file. To leave the file size optional, likely adds more complexity in the code to process and determine file size. |
- BaseDevice._get_free_space(file_system=None) — make the parameter optional so drivers like EOS (single filesystem) don't have to lie about the signature. Drops the `del file_system` workaround in EOS. - Pull the mocked-pyeapi setUp/tearDown out of TestRemoteFileCopy and TestFreeSpaceCheck into a shared _EOSDeviceMockedTestCase base. - Move the per-protocol FileCopyModel builder and the any_file_copy_model fixture out of the EOS and ASA integration test modules into tests/integration/_helpers.py + conftest.py so both drivers share one source of truth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
EOSDevice.file_copyandEOSDevice.remote_file_copyso transfers fail fast when flash lacks room for the image.BaseDevice(_get_free_spaceseam + concrete_check_free_spacehelper) so companion work for IOS, NXOS, JUNOS, and ASA only has to implement the per-platform probe.FileCopyModel.file_sizea required field with an optionalfile_size_unit(bytes/megabytes/gigabytes), mirroring how callers already declare the checksum.file_size_bytesis computed once in__post_init__.Implementation notes
NotEnoughFreeSpaceErrorgained optionalrequired/available/file_systemkwargs; the existing positional(hostname, min_space)signature is preserved soF5Device._check_free_spacekeeps working untouched._get_free_spaceparses the trailing(N bytes free)token fromdiroutput; thefile_systemargument is accepted for API parity but unused because EOS only exposes a single practical filesystem.remote_file_copy(HTTP / HTTPS / SCP / SFTP / FTP / TFTP) comparessrc.file_size_bytesagainst_get_free_space()after the scheme/URL validation and enable-session setup but before the copy command is built or sent — so an oversized transfer never reaches the device's copy machinery.file_copycomparesos.path.getsize(src)against_get_free_space()afterfile_copy_remote_exists()reports the file is missing.Breaking change
FileCopyModel(...)now requiresfile_size. Every in-repo call site (tests, integration, docs) has been updated; external consumers will see aTypeErroruntil they add the kwarg.Not in this PR
Test plan
poetry run pytest tests/unit -q— 651 passed (up from 639; 12 new)poetry run ruff check pyntc testspoetry run ruff format --check pyntc testspoetry run pylint pyntc— 10.00/10poetry run towncrier build --draftrenders thechanges/370.*fragments cleanlytests/integration/test_eos_device.py) — setEOS_HOST/EOS_USER/EOS_PASS+ per-protocol URL vars +FILE_CHECKSUM/FILE_SIZE/FILE_SIZE_UNIT; the new free-space tests include an oversized-transfer case that expectsNotEnoughFreeSpaceError.🤖 Generated with Claude Code