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.mdCh. 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
- The safe power-off:
GracefulShutdown→ if the host is hung it silently no-ops → detect that (read back) → escalate toForceOff→ confirm. This graceful→escalate→verify pattern is the difference between a toy and a tool (WARMUP Ch. 3). - 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).
- The guard:
_guard()records intent (audit), honorsdry_run(no mutation), and refuses destructive ops withoutconfirm. Physical actions demand this (WARMUP Ch. 8).
2. Extensions
- Point it at OpenBMC's
sushy-emulator(real Redfish): implementset_power/virtual-media over Redfish actions; the toolkit stays the same. - Add SoL capture: stream the host serial console during the reinstall and assert you see the bootloader.
- Add a power-on → POST-watch flow: power on, then poll for the host reaching a ready state (mirrors Phase 02 readiness).
- Add an interlock: refuse
power onif 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.