Textual TUI for cv4pve-cli: guest lifecycle, resources, context switching #1

Merged
Duckboot merged 2 commits from feat/guest-tui-mvp into main 2026-11-02 20:23:10 +01:00
Owner

What

A Textual TUI that wraps cv4pve-cli (it calls cv4pve-cli … -o json in a subprocess and stores no credentials).

  • Lists the VMs and LXC containers in the current cv4pve-cli context.
  • Starts (s), shuts down (S), stops (x, a hard power-off) and reboots (r) guests. Shutdown, stop and reboot ask for confirmation first.
  • Changes cores and memory (e), and tells you when a change will only take effect at the next reboot.
  • Grows a disk by a given amount (e). It cannot shrink one, and it asks again before growing because the change cannot be undone.
  • Lists the cv4pve-cli contexts and switches between them (c). The active context is always shown in the header.

Design and the CLI behaviour it relies on: docs/plans/guest-tui-mvp.md.

Notable points

  • Every call that changes something uses --wait. Without it, cv4pve-cli exits 0 even when the task fails.
  • After an action, the app reads that guest's status from status/current. /cluster/resources lags a few seconds behind, so without this the table would show the old status.
  • Switching context runs config use, which changes the global cv4pve-cli context. Version 2.4.0 has no way to choose a context for a single call.
  • A guest listing that was started before a context switch is discarded. Without this, the table could show the old cluster's guests, and since VMIDs repeat across clusters, an action could hit the wrong guest.

Verification

  • 103 tests pass; cv4pve-cli is mocked in all of them.
  • ruff check and ruff format --check report no issues.
  • betterleaks found no secrets.
  • Live test on CT 104 on mainframe: edit, shutdown, start and reboot all worked, and the container was restored to how it was before.
  • Live test of switching from mainframe to mainframe-edge and back.
  • Not run live: disk resize, because it cannot be undone.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

## What A Textual TUI that wraps `cv4pve-cli` (it calls `cv4pve-cli … -o json` in a subprocess and stores no credentials). - Lists the VMs and LXC containers in the current cv4pve-cli context. - Starts (`s`), shuts down (`S`), stops (`x`, a hard power-off) and reboots (`r`) guests. Shutdown, stop and reboot ask for confirmation first. - Changes cores and memory (`e`), and tells you when a change will only take effect at the next reboot. - Grows a disk by a given amount (`e`). It cannot shrink one, and it asks again before growing because the change cannot be undone. - Lists the cv4pve-cli contexts and switches between them (`c`). The active context is always shown in the header. Design and the CLI behaviour it relies on: `docs/plans/guest-tui-mvp.md`. ## Notable points - Every call that changes something uses `--wait`. Without it, `cv4pve-cli` exits 0 even when the task fails. - After an action, the app reads that guest's status from `status/current`. `/cluster/resources` lags a few seconds behind, so without this the table would show the old status. - Switching context runs `config use`, which changes the **global** cv4pve-cli context. Version 2.4.0 has no way to choose a context for a single call. - A guest listing that was started before a context switch is discarded. Without this, the table could show the old cluster's guests, and since VMIDs repeat across clusters, an action could hit the wrong guest. ## Verification - 103 tests pass; `cv4pve-cli` is mocked in all of them. - `ruff check` and `ruff format --check` report no issues. - `betterleaks` found no secrets. - Live test on CT 104 on mainframe: edit, shutdown, start and reboot all worked, and the container was restored to how it was before. - Live test of switching from mainframe to mainframe-edge and back. - Not run live: disk resize, because it cannot be undone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duckboot added 2 commits 2026-11-02 20:23:06 +01:00
List VMs and LXC containers from the current cv4pve-cli context and
start, shutdown, stop and reboot them, change cores and memory, and
grow disks. The app shells out to `cv4pve-cli -o json` and stores no
credentials.

- Every mutating call uses --wait: without it cv4pve-cli exits 0 even
  when the task fails.
- shutdown, stop and reboot need confirmation; disk growth is
  increment-only and asks again because it cannot be undone.
- After an action the acted-on guest's status is read from
  status/current, because /cluster/resources lags a few seconds.
- Notifies when a cores/memory change is pending until reboot.

Tests mock cv4pve-cli (85 tests). Live-tested edit, shutdown, start
and reboot on CT 104 (mainframe), restored afterwards; disk resize
was not run live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Press c to list cv4pve-cli contexts and switch between them. The
active context is always shown in the header.

- Switching runs `cv4pve-cli config use`, which changes the global
  current context. cv4pve-cli 2.4.0 has no per-call context option.
- `config list` has no JSON output, so its text lines are parsed.
- The guest table is cleared as soon as another context is chosen, so
  the old cluster's guests cannot be acted on.
- A generation counter drops guest listings that started before a
  switch, and g and c are refused while a switch runs. Without this,
  a reload already in flight could refill the table with the old
  cluster's guests, and VMIDs collide across clusters.

103 tests pass. The switch was tested live from mainframe to
mainframe-edge and back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Duckboot merged commit 62b79ab29e into main 2026-11-02 20:23:10 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Duckboot/cv4pve-cli-tui#1