API to get VMs where "onboot=1" (autostart) ?

luckman212

Renowned Member
Jun 22, 2017
59
12
73
I have some maintenance scripts where I need to pause/resume a set of VMs on my PVE 9.1 cluster. I want this script to operate on all VMs that are set to auto-start (onboot=1)

I found the /nodes/{node}/qemu API endpoint, but sadly the onboot parameter is not included in its output.

I can get what I'm after by looping over each node, getting a list of VMs with /nodes/{node}/qemu, and then iterating over every single VM ID with /nodes/{node}/qemu/{vmid}/config --output-format json | jq .onboot

...but with 3 nodes and 20-25 VMs, this ends up being 75 API calls to get a simple list of VMs that are set to autostart across the whole cluster.

Is there a more efficient way?
 
I reduced the # of API calls by writing a shell function and doing some of the heavy lifting in JQ, but it's still a but clunky. Ok, thanks for confirming at least. Maybe this is something that can be improved in the future.