How do you deal with asynchronous nature of proxmox API?

zerkms

New Member
Jan 23, 2013
16
0
1
Hi.

The case: I need to create a VM from the templae - it's pretty easy. I just send a post to the `/nodes/nodename/openvz`

And after it's created I need to start it.

This is where I'm in stuck: the `/nodes/nodename/openvz/{id}/status/current` returns the status `stopped` even while the machine isn't created from the template entirely.

So what is the best way to do that?

Yep, I may send `.../status/start` in a loop and check if `.../status/current` changed from stopped to run, but it doesn't look right.
 
The case: I need to create a VM from the templae - it's pretty easy. I just send a post to the `/nodes/nodename/openvz`

That 'POST' returns a string, which is a unique process ID ('upid'). You can query the status of that process on '/nodes/nodename/tasks/{upid}'.

Does that solve your problem?
 
That 'POST' returns a string, which is a unique process ID ('upid'). You can query the status of that process on '/nodes/nodename/tasks/{upid}'.

Does that solve your problem?

Yep, exactly what I needed thanks.