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.
 

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!