feat: configurable device toolchain
A new configurable device toolchain is now available, which will allow a user to run on an ssh capable device.
The ssh details can be passed in using string_flags for the bazel command.
A new SSHStrategy has been created for SSH Access to devices along with allowing the port to be specified as a str to override the NetworkService resources port.
This portion is required to allow passing in the port via the environment variable,
as part of the !template
functionality of the labgrid config.yaml.
Testing
I used a very simple docker image:
FROM ubuntu:24.04
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo "root:password" | chpasswd
RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config
CMD ["/usr/sbin/sshd", "-D"]
docker build -t ssh_device:latest .
Then to run:
docker run -d -p 2022:22 ssh_device:latest
Finally running a test, if you were to create a new bazel build file at e2e/configurable/BUILD.bazel
, that looks like:
load("@rules_labgrid//labgrid/genrule:defs.bzl", "labgrid_genrule")
platform(
name = "configurable-localhost",
constraint_values = [
"@rules_labgrid//labgrid/constraint/device:configurable",
],
parents = ["@local_config_platform//:host"],
visibility = ["//visibility:public"],
)
labgrid_genrule(
name = "os-release",
srcs = ["@ape//ape:cat"],
outs = ["stdout.log"],
cmd = "$(location @rules_labgrid//labgrid/run) $(location @ape//ape:cat) /etc/os-release > $@",
platform = ":configurable-localhost",
tools = ["@rules_labgrid//labgrid/run"],
)
You could then build it like so:
cd e2e
bazelisk build //configurable:os-release --@rules_labgrid//labgrid/flag/device:password=password --@rules_labgrid//labgrid/flag/device:port=2022
which should fill stdout.log
with this for the docker image above:
PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
Fixes #26 (closed)