Lab 01 — BMC Power Control, Sensors & Virtual Media

Phase: 04 — Hardware Interfacing | Difficulty: ⭐⭐⭐☆☆ | Time: 3–5 hours Language: Python 3 (stdlib only) | Hardware: none (BMC mock)

Concept primer: ../WARMUP.md Ch. 1–3, Ch. 8 (safety), ../HITCHHIKERS-GUIDE.md §1–§3, §8.

Run

python3 solution.py     # sensors, safe power-off (incl. hung-host escalation), vmedia reinstall

0. The mission

Build the toolkit behind "manage a server you can't physically touch": read sensors, power it safely, and reinstall its OS over the network with virtual media — with a dry-run/confirmation guard on every mutating operation. The BMC mock makes it runnable; the toolkit logic is the real pattern (swap in a Phase 03 Redfish/IPMI driver).

1. The three things to study

  1. The safe power-off: GracefulShutdown → if the host is hung it silently no-ops → detect that (read back) → escalate to ForceOff → confirm. This graceful→escalate→verify pattern is the difference between a toy and a tool (WARMUP Ch. 3).
  2. The virtual-media lifecycle: mount ISO → set next-boot to virtual CD → power-cycle → (installer runs, watched over SoL) → eject → restore boot-to-disk. This is remote provisioning's rescue path (Phase 05).
  3. The guard: _guard() records intent (audit), honors dry_run (no mutation), and refuses destructive ops without confirm. Physical actions demand this (WARMUP Ch. 8).

2. Extensions

  1. Point it at OpenBMC's sushy-emulator (real Redfish): implement set_power/virtual-media over Redfish actions; the toolkit stays the same.
  2. Add SoL capture: stream the host serial console during the reinstall and assert you see the bootloader.
  3. Add a power-on → POST-watch flow: power on, then poll for the host reaching a ready state (mirrors Phase 02 readiness).
  4. Add an interlock: refuse power on if a (Phase 04 Lab 02) CDU leak/critical signal is active.

3. What this lab proves

You can implement OOB server management correctly and safely — the operations the JD's "remote diagnostics," "operational support of deployed systems," and "firmware updates" all rest on. "Reinstall a server you can't touch" becomes a precise answer: virtual media + boot override + power-cycle + SoL, guarded and verified.