Skip to content

Commit 346180f

Browse files
committed
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 <[email protected]>
1 parent f81f479 commit 346180f

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

labgrid/util/agentwrapper.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ def __init__(self, host=None):
4646
agent = os.path.join(
4747
os.path.abspath(os.path.dirname(__file__)),
4848
'agent.py')
49+
agent_prefix = os.environ.get("LG_AGENT_PREFIX", "")
4950
if host:
5051
# copy agent.py and run via ssh
5152
with open(agent, 'rb') as agent_fd:
5253
agent_data = agent_fd.read()
5354
agent_hash = hashlib.sha256(agent_data).hexdigest()
54-
agent_remote = f'.labgrid_agent_{agent_hash}.py'
55+
agent_remote = os.path.join(agent_prefix, f'.labgrid_agent_{agent_hash}.py')
5556
connect_timeout = get_ssh_connect_timeout()
5657
ssh_opts = f'ssh -x -o ConnectTimeout={connect_timeout} -o PasswordAuthentication=no'.split()
5758
subprocess.check_call(

man/labgrid-client.1

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ CI pipelines where the username may not be consistent between pipeline stages.
124124
.sp
125125
Set the connection timeout when using SSH (The \fBConnectTimeout\fP option). If
126126
unspecified, defaults to 30 seconds.
127+
.SS LG_AGENT_PREFIX
128+
.sp
129+
Add a prefix to \fB\&.labgrid_agent_{agent_hash}.py\fP allowing specification for
130+
where on the exporter it should be uploaded to.
127131
.SH MATCHES
128132
.sp
129133
Match patterns are used to assign a resource to a specific place. The format is:

man/labgrid-client.rst

+5
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ LG_SSH_CONNECT_TIMEOUT
117117
Set the connection timeout when using SSH (The ``ConnectTimeout`` option). If
118118
unspecified, defaults to 30 seconds.
119119

120+
LG_AGENT_PREFIX
121+
~~~~~~~~~~~~~~~~~~~~~~
122+
Add a prefix to ``.labgrid_agent_{agent_hash}.py`` allowing specification for
123+
where on the exporter it should be uploaded to.
124+
120125
MATCHES
121126
-------
122127
Match patterns are used to assign a resource to a specific place. The format is:

0 commit comments

Comments
 (0)