| Crates.io | treadmill-cli |
| lib.rs | treadmill-cli |
| version | 0.2.0 |
| created_at | 2024-11-04 20:46:54.279611+00 |
| updated_at | 2025-04-30 22:50:37.801942+00 |
| description | CLI client for the Treadmill distributed hardware testbed |
| homepage | https://treadmill.ci |
| repository | |
| max_upload_size | |
| id | 1435704 |
| size | 107,218 |
Treadmill CLI is a command-line interface tool for interacting with the Treadmill test bench system. It provides functionality for user authentication and job management.
Ensure the CLI tool is in your system path or reference it directly using ./tml.
./tml [OPTIONS] <SUBCOMMAND>
-c, --config <FILE>: Sets a custom config file-u, --api-url <URL>: Sets the API URL directly-v, --verbose: Enable verbose loggingLogin
./tml login
Or, optionally:
./tml login <USERNAME> [<PASSWORD>]
./tml login <USERNAME> <PASSWORD>
Job Management
Enqueue a job:
./tml job enqueue <IMAGE_ID> [OPTIONS]
Options for job enqueue:
--ssh-keys <KEYS>: Comma-separated list of SSH public keys--restart-count <COUNT>: Remaining restart count--parameters <PARAMS>: JSON object of job parameters--tag-config <CONFIG>: Tag configuration--timeout <TIMEOUT>: Override timeout in secondsList all jobs:
./tml job list
Check job status:
./tml job status <JOB_ID>
Cancel a job:
./tml job cancel <JOB_ID>
SSH into a running job:
./tml job ssh <USER@IP>
If you run tml job ssh root@10.42.0.123, the CLI will:
~/.local/share/treadmill-tb/ssh-key.ssh -i ~/.local/share/treadmill-tb/ssh-key root@10.42.0.123.If the key already exists, it reuses that key to connect.
Treadmill CLI allows you to log in using several different methods, in order of precedence:
Positional Arguments
<USERNAME> [<PASSWORD>]./tml login ben mypassword
./tml login ben
In the second example, you’ll be prompted for the password.
Environment Variables
TML_USERTML_PASSWORDexport TML_USER=ben
export TML_PASSWORD=supersecret
./tml login
If these environment variables are set, the CLI will use them unless the above command-line arguments override them.
Interactive Prompt
Fully Interactive:
./tml login
Username Positional + Prompt for Password:
./tml login ben
benUsername & Password Positional:
./tml login ben mypassword
benmypasswordEnvironment Variables:
export TML_USER=ben
export TML_PASSWORD=supersecret
./tml login
bensupersecretNote: The CLI always checks for flags first, then any positional arguments, then environment variables, finally falling back to prompts for whichever piece is still missing. This flexibility makes the CLI suitable for both interactive and CI-based automation.
The CLI can be configured using a TOML file. You can specify the config file path using the -c option.
Example configuration:
ssh_keys = "ssh-rsa AAAAB3NzaC1yc2E..., ssh-ed25519 AAAAC3NzaC1lZDI1NTE5..."
[api]
url = "https://swb.treadmill.ci"
The CLI reads SSH keys from multiple sources:
.ssh directoryIf no SSH keys are provided via the command-line argument, the CLI will automatically attempt to read keys from these sources.
When you run tml job ssh <USER@IP>, Treadmill CLI will:
~/.local/share/treadmill-tb/ssh-key.0600).ssh command with -i ~/.local/share/treadmill-tb/ssh-key <USER@IP>.This ensures a consistent, Treadmill-managed SSH key without interfering with your other SSH configurations.
Login:
./tml login
CLI will prompt you for your username and password if they are not provided by any other means.
Enqueue a job:
./tml job enqueue 46ebc6946f7c4a10922bf1f539cd7351ce8670781e081d18babf1affdef6f577 \
--ssh-keys "ssh-rsa AAAAB3NzaC1yc2E...,ssh-ed25519 AAAAC3NzaC1lZDI1NTE5..." \
--restart-count 3 \
--parameters '{"key1":{"value":"value1","secret":false},"key2":{"value":"value2","secret":true}}' \
--tag-config 'test_tag_config' \
--timeout 3600
List all jobs:
./tml job list
Check job status:
./tml job status <JOB_ID>
Cancel a job:
./tml job cancel <JOB_ID>
SSH into a running job:
# Example: connect to user root at IP 10.42.0.123
./tml job ssh root@10.42.0.123
~/.local/share/treadmill-tb/ssh-key and then run:
ssh -i ~/.local/share/treadmill-tb/ssh-key root@10.42.0.123
To enable verbose logging, add the -v or --verbose flag to your command:
./tml -v job enqueue <IMAGE_ID>
This will output debug-level logs, which can be helpful for troubleshooting.
--parameters option requires a JSON string in the following format:
{
"key1": { "value": "value1", "secret": false },
"key2": { "value": "value2", "secret": true }
}
Each parameter must have a "value" (as a string) and a "secret" (as a boolean) field.For more detailed information about each command and its options, use the --help flag with any command or subcommand.