Pcornel
Virtualization · Automation

CLI Automation

Cheat sheet · https://pcornel.dk/topic.php?topic=3688

Back to the Topic

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 API
  • virsh list --all — libvirt CLI
  • esxcli vm process list — ESXi CLI

Commands

pvesh
pvesh get /nodes/pve1/tasks/<UPID>/status
qm agent 123 ping
qm unlock
virsh

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

Confirmation

Confirm action

Continue?