Automate / Script bulk suspend/start

Mareox

Member
Jun 9, 2022
1
0
6
Is it possible to schedule or automate using the pvecm or api the bulk start and suspend based on tags?
Here is an example: I would like to suspend all the devices (VMs / LXCs) with the tag: "night-sleep" and exclude those with the tag "always-on" every night at ceartin time.

1715843751056.png

And start those with the label "day-on" every morning at a specific time:

1715843777374.png
 
Hi,
you can get the current status of a VM including its tag via pvesh get /nodes/{node}/qemu/{VMID}/status/current or the corresponding api endpoint [0]. Based on that information you can then bulk suspend them via the suspendall endpoint [1] or the corresponding pvesh command pvesh create /nodes/{node}/suspendall --vms {VMIDs}.

[0] https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/status/current
[1] https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/suspendall
 
  • Like
Reactions: Kingneutron