-
Notifications
You must be signed in to change notification settings - Fork 11
tftp: add docs #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
tftp: add docs #267
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# TFTP Driver | ||
|
||
**driver**: `jumpstarter_driver_tftp.driver.Tftp` | ||
|
||
The TFTP driver provides a read-only TFTP server that can be used to serve files. | ||
|
||
## Driver Configuration | ||
```yaml | ||
export: | ||
tftp: | ||
type: jumpstarter_driver_tftp.driver.Tftp | ||
config: | ||
root_dir: /var/lib/tftpboot # Directory to serve files from | ||
host: 192.168.1.100 # Host IP to bind to (optional) | ||
port: 69 # Port to listen on (optional) | ||
``` | ||
|
||
### Config parameters | ||
|
||
| Parameter | Description | Type | Required | Default | | ||
|-----------|-------------|------|----------|---------| | ||
| root_dir | Root directory for the TFTP server | str | no | "/var/lib/tftpboot" | | ||
| host | IP address to bind the server to | str | no | auto-detect | | ||
| port | Port number to listen on | int | no | 69 | | ||
|
||
## TftpServerClient API | ||
|
||
```{eval-rst} | ||
.. autoclass:: jumpstarter_driver_tftp.client.TftpServerClient() | ||
:members: | ||
:show-inheritance: | ||
``` | ||
|
||
## Exception Classes | ||
|
||
```{eval-rst} | ||
.. autoclass:: jumpstarter_driver_tftp.driver.TftpError | ||
:members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: jumpstarter_driver_tftp.driver.ServerNotRunning | ||
:members: | ||
:show-inheritance: | ||
|
||
.. autoclass:: jumpstarter_driver_tftp.driver.FileNotFound | ||
:members: | ||
:show-inheritance: | ||
``` | ||
|
||
## Examples | ||
|
||
```{doctest} | ||
>>> import tempfile | ||
>>> import os | ||
>>> from jumpstarter_driver_tftp.driver import Tftp | ||
>>> with tempfile.TemporaryDirectory() as tmp_dir: | ||
... # Create a test file | ||
... test_file = os.path.join(tmp_dir, "test.txt") | ||
... with open(test_file, "w") as f: | ||
... _ = f.write("hello") | ||
... | ||
... # Start TFTP server | ||
... tftp = Tftp(root_dir=tmp_dir, host="127.0.0.1", port=6969) | ||
... tftp.start() | ||
... | ||
... # List files | ||
... files = tftp.list_files() | ||
... assert "test.txt" in files | ||
... | ||
... tftp.stop() | ||
``` | ||
|
||
```{testsetup} * | ||
import tempfile | ||
import os | ||
from jumpstarter_driver_tftp.driver import Tftp | ||
from jumpstarter.common.utils import serve | ||
|
||
# Create a persistent temp dir that won't be removed by the example | ||
TEST_DIR = tempfile.mkdtemp(prefix='tftp-test-') | ||
instance = serve(Tftp(root_dir=TEST_DIR, host="127.0.0.1")) | ||
client = instance.__enter__() | ||
``` | ||
|
||
```{testcleanup} * | ||
instance.__exit__(None, None, None) | ||
import shutil | ||
shutil.rmtree(TEST_DIR, ignore_errors=True) | ||
``` |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update docstring to accurately reflect server capabilities.
The docstring states this is a "read-only server", but the implementation includes write operations (
put_file
,delete_file
). This inconsistency could mislead users.Update the docstring to accurately reflect the server's capabilities:
📝 Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the server is read only though. the upload is done via the driver client, not the tftp server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bennyz I apologize for my confusion. You are absolutely correct - I now understand that while the driver provides file management capabilities through its client interface, the TFTP server itself is indeed read-only. The current docstring accurately reflects this architecture. Thank you for the clarification.
✏️ Learnings added