Automate / Script bulk suspend/start

Mareox

New Member
Jun 9, 2022
1
0
1
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

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!