From deab2fe33274bb325a39b536da6f792d5418db84 Mon Sep 17 00:00:00 2001 From: jrichardsen Date: Mon, 12 May 2025 09:10:35 +0200 Subject: [PATCH 1/3] Remove NFSProvider from ProviderGenericExport NFSProvider does no longer inherit from `BaseProvider` as of #1249 and, as such, does not have the corresponding `internal` and `external` parameters anymore. This leads to an error with `ProviderGenericExport` which expects these parameters (as it is meant for subclasses of `BaseProvider`). Signed-off-by: jrichardsen --- labgrid/remote/exporter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/labgrid/remote/exporter.py b/labgrid/remote/exporter.py index d3b406503..cf355bd56 100755 --- a/labgrid/remote/exporter.py +++ b/labgrid/remote/exporter.py @@ -594,7 +594,6 @@ def _get_params(self): exports["TFTPProvider"] = ProviderGenericExport -exports["NFSProvider"] = ProviderGenericExport exports["HTTPProvider"] = ProviderGenericExport From 27970a1aed7b1fcccd11d49aa83a90e728d686d3 Mon Sep 17 00:00:00 2001 From: jrichardsen Date: Mon, 12 May 2025 13:28:34 +0200 Subject: [PATCH 2/3] Add custom Export for NFSProvider Add `NFSProviderExport` for exporting `NFSProvider` to `RemoteNFSProvider`. Signed-off-by: jrichardsen --- labgrid/remote/exporter.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/labgrid/remote/exporter.py b/labgrid/remote/exporter.py index cf355bd56..8f12bd30b 100755 --- a/labgrid/remote/exporter.py +++ b/labgrid/remote/exporter.py @@ -596,6 +596,21 @@ def _get_params(self): exports["TFTPProvider"] = ProviderGenericExport exports["HTTPProvider"] = ProviderGenericExport +@attr.s +class NFSProviderExport(ResourceExport): + """Resource Export for an NFS provider""" + + def __attrs_post_init__(self): + super().__attrs_post_init__() + self.data["cls"] = "RemoteNFSProvider" + from ..resource import NFSProvider + + self.local = NFSProvider(target=None, name=None, **self.local_params) + + def _get_params(self): + return { "host": self.host } + +exports["NFSProvider"] = NFSProviderExport @attr.s class EthernetPortExport(ResourceExport): From af6458c9e58cfa3de38383f7a6bd3231d5d2e2ae Mon Sep 17 00:00:00 2001 From: jrichardsen Date: Mon, 19 May 2025 09:25:17 +0200 Subject: [PATCH 3/3] Add tests for exporting NFSProvider Signed-off-by: jrichardsen --- tests/test_export.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/test_export.py b/tests/test_export.py index f977322a8..c41328513 100644 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -1,8 +1,8 @@ import pytest -from labgrid.resource import Resource, NetworkSerialPort, TFTPProvider -from labgrid.resource.remote import RemoteNetworkInterface, RemoteTFTPProvider -from labgrid.driver import Driver, SerialDriver, NetworkInterfaceDriver, TFTPProviderDriver +from labgrid.resource import Resource, NetworkSerialPort, TFTPProvider, NFSProvider +from labgrid.resource.remote import RemoteNetworkInterface, RemoteTFTPProvider, RemoteNFSProvider +from labgrid.driver import Driver, SerialDriver, NetworkInterfaceDriver, TFTPProviderDriver, NFSProviderDriver from labgrid.strategy import Strategy from labgrid.binding import StateError @@ -110,3 +110,22 @@ def test_export_remote_tftp_provider(target): 'LG__TFTP_INTERNAL': '/srv/tftp/testboard/', 'LG__TFTP_EXTERNAL': 'testboard/', } + +def test_export_nfs_provider(target): + NFSProvider(target, None) + NFSProviderDriver(target, "nfs") + + exported = target.export() + assert exported == { + 'LG__NFS_HOST': 'localhost', + } + + +def test_export_remote_nfs_provider(target): + RemoteNFSProvider(target, None, host='testhost') + NFSProviderDriver(target, "nfs") + + exported = target.export() + assert exported == { + 'LG__NFS_HOST': 'testhost', + }