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: