CLI Reference — sre¶
sre --help groups subcommands into five buckets: dual (admins + GUI via sre-wrapper), admin-only, exam management, post-exam management, and internal (GUI-only).
Global options¶
sre [--user] [--debug] <subcommand> ...
Option |
Description |
|---|---|
|
Set by |
|
Verbose diagnostics to stderr. |
Access is restricted to root, the sre user (params.sre_uid = 1100), members of params.admin_uids, or members of any params.admin_gids group. Non-privileged users may only run cat, check-eval, re-eval, sheet, and outline.
Dual commands¶
sre start [-d data] [-p] [--flavor … | --flavor-json … | --set-flavor-name …] [--xauth-file <file>] <lab> [data_version]¶
Starts a new lab instance, named {timestamp}@@@{lab_name}@@@{username}. Imports srelab.py, runs Data.generate(flavor) (or loads -d data.json), builds NetScheme, pulls images, deploys via Kathara, applies the initial state, and writes info.json + scheme.svg. See Internals for file-transfer and progress mechanics.
Argument / Option |
Description |
|---|---|
|
Lab name (from |
|
Treat |
|
Reuse an existing |
|
Optional seed for |
|
Flavor field values (e.g. |
|
Flavor as JSON dict (used by the GUI). |
|
Use a named preset |
|
Read |
sre stop <running_lab>¶
Undeploys containers and removes the project directory from /var/lib/sre/projects/.
sre wipe¶
Stops every running Kathara lab and removes everything under /var/lib/sre/projects/.
sre connect [--shell <shell>] [--exec <argument…>] [--no-records] <running_lab> <device>¶
Opens an external terminal connected to a container.
Option |
Description |
|---|---|
|
Override the machine default shell (privileged only). |
|
Run one command via the shell and return (consumes rest of argv). |
|
Do not record the terminal session (privileged only). |
sre eval [-p path] [--auto-eval] <running_lab>¶
Evaluates a running lab. The atomic lock file .private/eval_in_progress prevents concurrent evals.
--auto-eval marks a user-triggered self-evaluation (sent by the GUI’s Start evaluation). With --user, it enables the delay_between_self_grade cooldown (outside exam mode), appends a line to .private/auto_eval.log, and prints the result JSON. Without --auto-eval, a --user invocation runs silently — no cooldown, no log, no stdout. The auto_eval_count (lines in .private/auto_eval.log before this run) is assigned to self.auto_eval_count and embedded in the archive’s answers. If the lab sets no_mark_on_self_grade, letter grades (OK/MEH/FAIL) replace numeric grades. Results are archived as .zst — see Archive format.
sre state <running_lab> <state_name>¶
Applies NetScheme.<state_name>() to a running lab. File operations registered via file() / append_to_file() are injected via in-memory tar archives sent to container.put_archive("/").
Admin-only commands¶
sre exec [--shell <shell>] <running_lab> <device> <command…>¶
Runs shell -c <command> in a container and forwards stdout/stderr/exit code. Default shell is params.default_exec_shell.
sre eval-all [--display-grades / --no-display-grades]¶
Evaluates every running lab instance concurrently. --no-display-grades suppresses the per-lab grade summary.
sre check [-p] <lab> [<state>]¶
Validates a lab module without deploying: imports it, runs Data.generate(), builds NetScheme, runs initial(), calls Grade.grade(). With state, also validates that state method.
sre watch [--timeout <sec>] [--interval <sec>] <dir…>¶
Live terminal dashboard scanning <dir…> for .zst archives. Default refresh: params.default_dashboard_refresh_interval_in_watch_command. --timeout is the inactivity-alert threshold (default 90 s).
Columns (from each archive):
Column |
Source |
|---|---|
HOSTNAME / LOGIN |
|
LAB NAME |
Middle segment of |
GRADE |
|
ERR |
Length of |
LAST EVAL |
|
TIME REMAINING |
|
Keys:
Key |
Context |
Action |
|---|---|---|
|
Any |
Toggle focus between Projects and Alerts |
|
Projects / Alerts |
Move selection |
|
Projects |
Dismiss selected project |
|
Projects |
Dismiss all projects from the selected hostname |
|
Projects |
Set a hostname regexp filter (empty = show all) |
|
Either |
Un-dismiss all |
|
Alerts |
Dismiss selected alert |
|
Any |
Quit |
|
Any |
Toggle help |
Dismissals self-expire: inactivity alerts return on new archives, error alerts return when the count changes.
sre preload-images [--random-delay <sec>] <file_or_dir…>¶
Scans lab .py files for image= / 'image': patterns and docker pulls each unique image. --random-delay <sec> waits 0–N seconds before pulling (smooths thundering-herd when invoked across many hosts).
sre make-titles [-o <file> | -r] <directory>¶
Generates titles.json sidecars so the GUI shows friendly labels (e.g. static_routing.py → “Static routing”). Labs without a title attribute are skipped.
Option |
Description |
|---|---|
|
Write all titles to |
|
One |
Output keys match sre list: "<name>.py" for file labs, "<dirname>" for directory labs. Files are written atomically with sorted keys; stale entries are dropped at read time by sre list --with-titles.
{
"static_routing.py": {"en": "Static routing", "fr": "Routage statique"},
"tp_ssh": {"en": "SSH lab", "fr": "TP SSH"}
}
Typical usage: sudo /opt/sre/sbin/sre make-titles -r /opt/sre/lab.
Exam management¶
Exam state lives in /var/lib/sre/exam.json — see Exam Reference for the field schema. All field names are exposed as params.exam_* constants.
sre set-exam [options]¶
Creates or updates exam.json. Only provided options are updated; existing fields are preserved.
Option |
Description |
|---|---|
|
Authorised labs, optionally with a named flavor preset (e.g. |
|
Exam opens after this moment. ISO ( |
|
Exam closes before this moment. |
|
Max duration; ends at |
|
Period between automatic evals (default 60). |
|
Record terminal sessions ( |
sre del-exam¶
Removes exam.json and wipes all running projects.
sre save-records -d <dir> [--only-last-record]¶
Archives the records/ directories of running projects as .tar.gz files in <dir>. --only-last-record deletes prior archives for the same project so only the latest remains.
Post-exam management¶
Reads and transforms .zst evaluation archives — see Archive format for the schema.
sre cat [options] <file…>¶
Prints archive contents. Without a field option, all fields are shown.
Option |
Shows |
|---|---|
|
|
|
Raw test results per machine |
|
Evaluation errors |
|
Student answers |
|
Grade list, total grade, total max |
|
Files saved in the archive |
|
Extract saved files to the current directory |
|
Emit a single JSON dict per file on stdout |
sre check-eval [-s <srelab>] <file…>¶
Diffs stored grades against a re-grade (same logic as re-eval but without writing files). Prints per-element changes plus a summary count. -s selects an updated srelab.py or directory; if omitted, uses each archive’s .private/srelab symlink.
sre re-eval -s <srelab> -p <prefix> [-d <outdir>] [-r] <file_or_dir…>¶
Re-grades archives with an updated srelab.py. Useful for fixing a grading bug post-exam.
Option |
Description |
|---|---|
|
Updated |
|
Prepended to each output archive filename. |
|
Output directory (default: current). |
|
Recurse into subdirectories. |
sre sheet -o <output.ods> [-r] <file_or_dir…>¶
Exports archives to a LibreOffice ODS spreadsheet. Per distinct lab name, three sheets are produced:
Sheet |
Content |
|---|---|
|
One row per archive: |
|
Per-question: |
|
Per-student best score: |
fullname and email come from the archive’s answers (empty if absent).
sre outline [-o <summary.ods>] [-d <pdf_dir>] [-r] [--lang <lang>] [--no-timeline] [--remaining-time] [--users-file <file>] <file_or_dir…>¶
Generates per-student PDF reports plus a summary ODS — best-graded archive per student. At least one of -o / -d is required.
Option |
Description |
|---|---|
|
Output |
|
Output dir for PDFs (omit to skip). |
|
Recurse into subdirectories. |
|
Force PDF language (e.g. |
|
Omit the evaluation-history table. |
|
Include the time-remaining column in the history. |
|
User list |
Name / email resolution: --users-file (if provided) → fullname / email from archive answers. Columns appear only when at least one student has a non-empty value.
Internal commands (GUI-only)¶
sre list [--with-titles]¶
Prints a JSON array of lab names relative to /opt/sre/lab/ (s4/tp_ssh, s2/lab.py, …). Labs whose components match params.exam_only_affix (_EXAM_, _OLD_, _DRAFT_, _TESTS_) are hidden.
With --with-titles, output becomes [{"name": <path>, "title": <dict|null>}, …] — titles come from per-directory titles.json (see sre make-titles); stale entries are dropped, and labs missing a title get "title": null (GUI then falls back to the filename).
sre export <running_lab> [--sep <N>] [--curved] [--shapes] [--reverse] [--random-seed <N>]¶
Exports a running project as a Kathara zip archive, base64-encoded on stdout. Flags tune the embedded schema: --sep 0–9 (default 3), --curved for curved edges, --shapes for geometric nodes, --reverse to flip insertion order, --random-seed for node-order permutation.
sre pre-start-exam¶
Stops non-exam projects, then starts all exam labs so images are pre-pulled. Called by the GUI ~60 s before start_after.
sre start-exam¶
Stamps started_at in exam.json. Called by the GUI once now ≥ start_after.
sre eval-exam¶
Evaluates every running exam project concurrently. Called by the GUI on a periodic timer (every eval_interval) and once at exam end.
sre end-exam¶
Stamps ended_at and runs a final concurrent eval on every running exam project. Called by the GUI when the exam ends.