Pcornel
Virtualization · Automation

APIs

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

Back to the Topic

Answer

Hypervisor APIs (vSphere API, Hyper-V WMI/PowerShell, libvirt, Proxmox REST, cloud provider APIs) expose VM, network and storage operations to scripts and tools; authenticate with a scoped service account and use the API's task status to confirm results.

Remember

  • HTTP 200 on a task ≠ the task succeeded.
  • API permissions follow the service account's roles.
  • API versions differ between platform releases.

First checks

  • curl -s -H 'Authorization: PVEAPIToken=<user>@pam!<id>=<secret>' https://<host>:8006/api2/json/version — Proxmox API
  • Invoke-RestMethod https://vcenter/api/session -Method Post -Credential $c — vCenter REST
  • virsh -c qemu+ssh://<host>/system list — libvirt remote API

Commands

pvesh
curl
virsh

Verify in this order

client → authenticated API → management service

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=3687

Confirmation

Confirm action

Continue?