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

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

class jumpstarter_driver_tftp.client.TftpServerClient

Bases: DriverClient

Client interface for TFTP Server driver

This client provides methods to control a TFTP server and manage files on it. Supports file operations like uploading from various storage backends through OpenDAL.

delete_file(filename: str)

Delete a file from the TFTP server

Args:

filename (str): Name of the file to delete

Raises:

FileNotFound: If the specified file doesn’t exist TftpError: If deletion fails for other reasons

get_host() str

Get the host address the TFTP server is listening on

Returns:

str: The IP address or hostname the server is bound to

get_port() int

Get the port number the TFTP server is listening on

Returns:

int: The port number (default is 69)

list_files() list[str]

List files in the TFTP server root directory

Returns:

list[str]: A list of filenames present in the TFTP server’s root directory

start()

Start the TFTP server

Initializes and starts the TFTP server if it’s not already running. The server will listen on the configured host and port.

stop()

Stop the TFTP server

Stops the running TFTP server and releases associated resources.

Raises:

ServerNotRunning: If the server is not currently running

Exception Classes

class jumpstarter_driver_tftp.driver.TftpError

Bases: Exception

Base exception for TFTP server errors

class jumpstarter_driver_tftp.driver.ServerNotRunning

Bases: TftpError

Server is not running

class jumpstarter_driver_tftp.driver.FileNotFound

Bases: TftpError

File not found

Examples

>>> 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()