From b099c5b805685dc7eb18304835536010c8cb61ea Mon Sep 17 00:00:00 2001 From: javierbrk Date: Mon, 16 Nov 2026 22:16:22 -0300 Subject: [PATCH 1/2] fix new url format for tftp --- strategies/tftpstrategy.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/strategies/tftpstrategy.py b/strategies/tftpstrategy.py index 33a4633..8bb5c09 100644 --- a/strategies/tftpstrategy.py +++ b/strategies/tftpstrategy.py @@ -7,6 +7,7 @@ import threading import time from contextlib import contextmanager +from urllib.parse import urlparse import attr from labgrid.driver import TFTPProviderDriver @@ -16,6 +17,21 @@ logger = logging.getLogger(__name__) + +def _split_staged(staged): + """Return (bootfile, server_ip) for a file staged by TFTPProviderDriver. + + Exporter configs following current openwrt-tests set the TFTPProvider + ``external`` to a full ``tftp:////`` URL; older ones use a + plain relative path. U-Boot needs the bare path as ``bootfile``: given the + URL verbatim it asks the server for a file literally named ``tftp://...``. + """ + parsed = urlparse(staged) + if parsed.scheme == "tftp": + return parsed.path.lstrip("/"), parsed.hostname + return staged, None + + TFTP_DOWNLOAD_TIMEOUT = 120 TFTP_RETRY_INTERVAL = 5 DEFAULT_UBOOT_RETRIES = 2 @@ -467,17 +483,20 @@ def _power_cycle_for_uboot(self): def _transition_to_uboot_once(self): """Power-cycle the node and activate the U-Boot console.""" self.target.activate(self.tftp) - staged_file = self.tftp.stage(self.target.env.config.get_image_path("root")) + staged_file, url_server_ip = _split_staged( + self.tftp.stage(self.target.env.config.get_image_path("root")) + ) staged_initrd = None try: initrd_path = self.target.env.config.get_image_path("initrd") - staged_initrd = self.tftp.stage(initrd_path) + staged_initrd, _ = _split_staged(self.tftp.stage(initrd_path)) logger.info("Staged initrd image: %s", staged_initrd) except KeyError: pass - tftp_server_ip = self._resolve_tftp_server_ip() + # Precedence: TFTP_SERVER_IP env, exporter external_ip, host of the URL. + tftp_server_ip = self._resolve_tftp_server_ip() or url_server_ip self.target.deactivate(self.console) self.target.activate(self.power) From 4c39f8e960939a0389eeb4315d011cae81cdd3d2 Mon Sep 17 00:00:00 2001 From: javierbrk Date: Mon, 16 Nov 2026 22:47:48 -0300 Subject: [PATCH 2/2] style: apply ruff format --- strategies/tftpstrategy.py | 4 +--- tests/conftest_mesh.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/strategies/tftpstrategy.py b/strategies/tftpstrategy.py index 8bb5c09..912f14e 100644 --- a/strategies/tftpstrategy.py +++ b/strategies/tftpstrategy.py @@ -524,9 +524,7 @@ def transition_to_uboot_with_retry(self): cooldown = _read_int_env( "LG_MESH_UBOOT_RETRY_COOLDOWN", DEFAULT_UBOOT_RETRY_COOLDOWN ) - budget = _read_int_env( - "LG_MESH_UBOOT_RETRY_BUDGET", DEFAULT_UBOOT_RETRY_BUDGET - ) + budget = _read_int_env("LG_MESH_UBOOT_RETRY_BUDGET", DEFAULT_UBOOT_RETRY_BUDGET) _retry_action( self._transition_to_uboot_once, lambda: self.transition(Status.off), diff --git a/tests/conftest_mesh.py b/tests/conftest_mesh.py index cabf921..0c52678 100644 --- a/tests/conftest_mesh.py +++ b/tests/conftest_mesh.py @@ -407,9 +407,7 @@ def _launch_boot_subprocess( stop_file, ] - logger.info( - "Launching boot subprocess for %s (budget %ds)", place, boot_budget - ) + logger.info("Launching boot subprocess for %s (budget %ds)", place, boot_budget) child_env = dict(os.environ) child_env["LG_MESH_BOOT_BUDGET"] = str(boot_budget)