Closed ghost closed 5 years ago
Indeed this would be useful for us too. Should I go on and create a PR?
For the second part of the issue, the client has a function named 'add-named-match' this allows to set the match by name:
~/tmp/labgrid-test labgrid-client -p remoteboards add-named-match dibooki/board1/NetworkService network-board1
~/tmp/labgrid-test labgrid-client -p remoteboards show
Place 'remoteboards':
aliases:
comment:
matches:
dibooki/board1/NetworkService → network-board1
acquired: None
acquired resources:
allowed:
created: 2018-09-05 18:30:53.411019
changed: 2018-09-05 18:32:10.518305
Matching resource 'network-board1' (dibooki/board1/NetworkService/NetworkService):
{'acquired': None,
'avail': True,
'cls': 'NetworkService',
'params': {'address': '1.1.1.1', 'name': 'network-board1', 'username': 'root'}}
The named match is indicated by the small arrow above. I think the first part may also be caused by using a normal match. Please test the function, I'll add documentation for the feature.
@cadenv and @avoine Is this still an issue for you? Otherwise I'd close this.
@cadenv, @avoine I'll close this issue for now, feel free to open a new one if your still encounter a problem with named resources.
Goal is to run tests on a distributed setup where an exporter provides multiple named resources of the same type that are bound to drivers on the client.
Example exporter config
Example environment config
This setup exposes two potential errors, one at the client and one at the exporter
When calling make_resource labgrid/resource/remote.py does not remove the name key from the arguments, as done in ./labgrid/factory.py
Here is a fix for the problem
The following is observed for the setup
We observe that the services are named
remote/board1/NetworkService/NetworkService
andremote/board2/NetworkService/NetworkService
, while we expectremote/board1/NetworkService/network-board1
andremote/board2/NetworkService/network-board2
The client uses the same resource_name
NetworkService
as a key in directories for both resources, which makes only one of them available, when checking the environmentand when running a test
A fix is to check if a name for the resource is provided in the arguments at the exporter
In general the code is sometimes confusing, as resource_name as variable is often used for the type of the resource, for example NetworkService.