[PVE-User] Proxmox API catch response

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Feb 5 15:34:48 CET 2016

If it's a call where a worker gets forked we have an UPID which 
represents this action and we have a UPID wait function where you can 
wait for this task to finish.

If you're making perl scripts on a PVE host it'd be really easy:

>     use PVE::API2::Qemu;
>     use PVE::ProcFSTools;
>     my $params = {
>     node => $nodename,
>     vmid => $id,
>     timeout => $shutdown_timeout,
>     forceStop => 1,
>     };
>     my $upid = PVE::API2::Qemu->vm_shutdown($params);
>     PVE::ProcFSTools::upid_wait($upid);
>     # more code here

But I'm simply guessing you do something else than perl.

But you get the UPID also when making API calls in another way (through 
REST calls, e.g.) so you could check on that task.
You will almost always need a loop with waits somewhere but you can make 
one function like upid_wait and use that everywhere.

To see how the UPID is calculated look at:

For an upid_wait function implementation see;

===== more easier approach ======

A bit complicated maybe, also polling the task (which is also defined by 
the UPID) until it has "stopped" as status would be ok:

Something like (using pseudo code):

> do {
>     sleep (1)
>     task = APICALL(get 
> nodes/nina/tasks/UPID:nina:00007F77:0029667A:56B36272:vncproxy:104:tom at pam:/status)
> } while (task->{status} != 'stopped')

On 02/05/2016 02:09 PM, Mohamed Sadok Ben Jazia wrote:
> Hello list,
> i'm using proxmox api to create Containers and managing ressources.
> proxmox commands don't have a fixed duration so you need to refresh 
> calls to see that an action is correctly done..
> Are there a method to catch the end of an action when using API calls?
> _______________________________________________
> pve-user mailing list
> pve-user at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-user/attachments/20160205/181976ca/attachment.htm>

More information about the pve-user mailing list