Skip to content

feat(lxc): LXC lifecycle write path — start/stop/shutdown/delete + CLI#17

Merged
ChrisonSimtian merged 1 commit into
mainfrom
feat/149-lxc-lifecycle
Jun 20, 2026
Merged

feat(lxc): LXC lifecycle write path — start/stop/shutdown/delete + CLI#17
ChrisonSimtian merged 1 commit into
mainfrom
feat/149-lxc-lifecycle

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Adds PctWriter, the container counterpart to QemuWriter (#14) — an IaC write path to start/stop/shutdown/destroy an LXC, so decommissioning a CT no longer needs root SSH + pct.

Motivated by Chrison-dev/Homelab#149: retiring Teleport CT 9904 had no sanctioned write path (proxmoxsharp was read-only).

What

  • src/ProxmoxSharp/Lxc/PctWriter.csStartAsync, StopAsync (hard kill), ShutdownAsync (graceful + hard-stop fallback via forceStop/timeout), DeleteAsync (force + purge). Mirrors QemuWriter: raw form requests over the shared Kiota adapter (lifecycle ops carry query flags the typed builders can't express), same token-auth/TLS + error-body surfacing (fix: surface Proxmox error body instead of opaque status code #16), returns a task UPID; WaitForTaskAsync polls it.
  • CLIproxmoxsharp lxc <start|stop|shutdown|delete> <node> <vmid>. delete is gated on --confirm, with --force / --no-purge, same discipline as vm delete.
  • Tests — pure query-builder helpers (DeleteQuery / ShutdownQuery) unit-tested (5 new). Full suite green (37 passed, 3 pre-existing skips).

Notes

  • Deliberately uses raw requests (not the generated builders) so the query flags are expressed uniformly — same approach as QemuWriter.DeleteAsync. The form-send + task-poll helpers mirror QemuWriter; a shared base can be hoisted if a third writer appears.
  • Live verification (actual stop/destroy against the cluster) is manual, like the VM write path.

Relates to Chrison-Homelab/Homelab#149 and the converge destroy lifecycle (#101).

🤖 Generated with Claude Code

Adds PctWriter, the container counterpart to QemuWriter (#14), giving an IaC write
path to tear a CT down instead of root SSH + pct. Motivated by Chrison-Homelab/Homelab#149
(decommissioning Teleport CT 9904 had no sanctioned write path).

- PctWriter: StartAsync / StopAsync (hard kill) / ShutdownAsync (graceful + hard-stop
  fallback) / DeleteAsync (force + purge). Mirrors QemuWriter — raw form requests over
  the shared Kiota adapter (lifecycle ops carry forceStop/timeout/force/purge query
  flags), same token-auth/TLS + error-body surfacing, returns a task UPID; WaitForTaskAsync.
- CLI: `proxmoxsharp lxc <start|stop|shutdown|delete> <node> <vmid>`; delete is gated on
  --confirm with --force/--no-purge, same discipline as `vm delete`.
- Pure query-builder helpers (DeleteQuery/ShutdownQuery) unit-tested (5 new; suite green).

Relates to Chrison-Homelab/Homelab#149 and the converge destroy lifecycle (#101).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ChrisonSimtian
ChrisonSimtian merged commit 7787f5d into main Jun 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant