CLI Automation
Cheat sheet · https://pcornel.dk/topic.php?topic=3688
Answer
CLI automation drives hypervisors from shell scripts with tools like virsh and virt-install (KVM), qm (Proxmox), govc or esxcli (vSphere) and Hyper-V PowerShell, which suits quick bulk changes and troubleshooting.
Remember
- CLI output formats change between versions; parse carefully.
- Run read-only commands first.
- Root shell on a host bypasses central audit.
First checks
pvesh get /nodes— Proxmox CLI over APIvirsh list --all— libvirt CLIesxcli vm process list— ESXi CLI
Commands
pveshpvesh get /nodes/pve1/tasks/<UPID>/statusqm agent 123 pingqm unlockvirsh
Verify in this order
script → CLI → API/hypervisor
Where it usually breaks
First mismatch in management intent → host/cluster capability → hypervisor runtime/task → virtual resource/device → guest state → workload-visible read-back; preserve identity/native error/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=3688