The correct way to enumerate free CT/VMIDs?

Faye

Member
Jan 2, 2012
39
0
6
Hi,

I'm writing some scripting to automate environment creation and would like to know the correct way to ask for the next available CTID. I was running qm & vzlist but now that I have two nodes, this is not sufficient as it neglects the containers currently on another node.

Thanks
 
I wonder if it's ok to simply sqlite3 config.db select * from tree where name like '%.conf' ?
(assuming I don't pollute my etc/pve)


Faye
 
I wonder if it's ok to simply sqlite3 config.db select * from tree where name like '%.conf' ?
(assuming I don't pollute my etc/pve)

No - please do not query the DB directly.

Instead use the api call "GET /cluster/resources", or simply read the file "/etc/pve/.vmlist" (JSON format).
 
perfect answer Dietmar, thank you.

I just want to say that I love that you drop shell-useful files like this and that the configfs makes this possible. You've made my RAD scripting way more Rapid than it would have been had I needed to learn an API before I could even try things.
 
Last edited:

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!