Method of to determine if proxmox rest api call has completed

whiggs

New Member
Dec 11, 2024
25
0
1
Hello everyone. I am trying to automate the creation of a bunch of vms using the rest api call, but I am running into a bit of a problem. As far as I am aware, the rest api does not provide a means that would allow the a script to determine if a previous call to the rest api has completed or not, which is a problem, Since the rest api calls are asynchronous. This has resulted in a scenario where I essentially have to wait for an extended period of time and hope that the previous rest api call completed, because the tasks will just start failing if too many of them are running simultaneously. Is there a way for a script to determine if the job associated with a previous rest api call has completed or is still running? If this has not been implemented yet, I think the ideal way in which you could implement such a function would be to have each call to the rest api return a object, and have one of the properties associated with that object track the status of the job on the proxmox server and return a simple true or false if the job has completed.
 
Keep an eye on this bug: https://bugzilla.proxmox.com/show_bug.cgi?id=3931

In the meantime, you just have to find a way to filter the task output and find the right task, ie:
status=$($SSHTRG pvesh get /nodes/$PEER/tasks --output-format json| jq -r '[.[] | select(.type == "clusterjoin")] | sort_by(.endtime) | .[-1] | .status')


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Johannes S