From a1141a3f307ff25885193862a13aa198059e37d6 Mon Sep 17 00:00:00 2001 From: "Benjamin B. Frost" Date: Mon, 20 Jan 2025 12:01:15 +0100 Subject: [PATCH] agentwrapper: Allow specifying agent prefix Allows client to specify where on the exporter .labgrid_agent_{agent_hash}.py should be copied to. Default is the user homedir. Signed-off-by: Benjamin B. Frost --- labgrid/util/agentwrapper.py | 3 ++- man/labgrid-client.1 | 4 ++++ man/labgrid-client.rst | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/labgrid/util/agentwrapper.py b/labgrid/util/agentwrapper.py index fd23a4031..f505b861d 100644 --- a/labgrid/util/agentwrapper.py +++ b/labgrid/util/agentwrapper.py @@ -46,12 +46,13 @@ def __init__(self, host=None): agent = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'agent.py') + agent_prefix = os.environ.get("LG_AGENT_PREFIX", "") if host: # copy agent.py and run via ssh with open(agent, 'rb') as agent_fd: agent_data = agent_fd.read() agent_hash = hashlib.sha256(agent_data).hexdigest() - agent_remote = f'.labgrid_agent_{agent_hash}.py' + agent_remote = os.path.join(agent_prefix, f'.labgrid_agent_{agent_hash}.py') connect_timeout = get_ssh_connect_timeout() ssh_opts = f'ssh -x -o ConnectTimeout={connect_timeout} -o PasswordAuthentication=no'.split() subprocess.check_call( diff --git a/man/labgrid-client.1 b/man/labgrid-client.1 index c4ccaa681..72202cfe8 100644 --- a/man/labgrid-client.1 +++ b/man/labgrid-client.1 @@ -124,6 +124,10 @@ CI pipelines where the username may not be consistent between pipeline stages. .sp Set the connection timeout when using SSH (The \fBConnectTimeout\fP option). If unspecified, defaults to 30 seconds. +.SS LG_AGENT_PREFIX +.sp +Add a prefix to \fB\&.labgrid_agent_{agent_hash}.py\fP allowing specification for +where on the exporter it should be uploaded to. .SH MATCHES .sp Match patterns are used to assign a resource to a specific place. The format is: diff --git a/man/labgrid-client.rst b/man/labgrid-client.rst index ae8a61086..a2374ae7e 100644 --- a/man/labgrid-client.rst +++ b/man/labgrid-client.rst @@ -116,6 +116,11 @@ LG_SSH_CONNECT_TIMEOUT Set the connection timeout when using SSH (The ``ConnectTimeout`` option). If unspecified, defaults to 30 seconds. +LG_AGENT_PREFIX +~~~~~~~~~~~~~~~~~~~~~~ +Add a prefix to ``.labgrid_agent_{agent_hash}.py`` allowing specification for +where on the exporter it should be uploaded to. + MATCHES ------- Match patterns are used to assign a resource to a specific place. The format is: