Skip to content

Commit a1141a3

Browse files
benjamin1313Emantor
authored andcommitted
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 cea524d commit a1141a3

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
@@ -116,6 +116,11 @@ LG_SSH_CONNECT_TIMEOUT
116116
Set the connection timeout when using SSH (The ``ConnectTimeout`` option). If
117117
unspecified, defaults to 30 seconds.
118118

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

0 commit comments

Comments
 (0)