<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
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.<br>
<br>
If you're making perl scripts on a PVE host it'd be really easy:<br>
<br>
<blockquote type="cite"><br>
use PVE::API2::Qemu;<br>
use PVE::ProcFSTools;<br>
<br>
my $params = {<br>
node => $nodename,<br>
vmid => $id,<br>
timeout => $shutdown_timeout,<br>
forceStop => 1,<br>
};<br>
<br>
my $upid = PVE::API2::Qemu->vm_shutdown($params);<br>
PVE::ProcFSTools::upid_wait($upid);<br>
<br>
# more code here</blockquote>
<br>
But I'm simply guessing you do something else than perl.<br>
<br>
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.<br>
You will almost always need a loop with waits somewhere but you can
make one function like upid_wait and use that everywhere.<br>
<br>
To see how the UPID is calculated look at:<br>
<a class="moz-txt-link-freetext" href="https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/Tools.pm;h=9f08aa6fbf0c08da62e2f17078684cc2136d5b14;hb=HEAD#l854">https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/Tools.pm;h=9f08aa6fbf0c08da62e2f17078684cc2136d5b14;hb=HEAD#l854</a><br>
<br>
For an upid_wait function implementation see;<br>
<a class="moz-txt-link-freetext" href="https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/ProcFSTools.pm;h=516c0e8b939791a64771df41c36df362e65c7423;hb=HEAD#l355">https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/ProcFSTools.pm;h=516c0e8b939791a64771df41c36df362e65c7423;hb=HEAD#l355</a><br>
<br>
===== more easier approach ======<br>
<br>
A bit complicated maybe, also polling the task (which is also
defined by the UPID) until it has "stopped" as status would be ok:<br>
<br>
Something like (using pseudo code):<br>
<br>
<br>
<blockquote type="cite">do {<br>
sleep (1)<br>
task = APICALL(get
nodes/nina/tasks/UPID:nina:00007F77:0029667A:56B36272:vncproxy:104:tom@pam:/status)<br>
} while (task->{status} != 'stopped')</blockquote>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 02/05/2016 02:09 PM, Mohamed Sadok
Ben Jazia wrote:<br>
</div>
<blockquote
cite="mid:CAKATEKin8WnRMvg0CeV7_v3n9zPxc+ANuc_TifJ729ZgF6_Sgw@mail.gmail.com"
type="cite">
<div dir="ltr">Hello list,
<div>i'm using proxmox api to create Containers and managing
ressources.</div>
<div>proxmox commands don't have a fixed duration so you need to
refresh calls to see that an action is correctly done..</div>
<div>Are there a method to catch the end of an action when using
API calls?</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
pve-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:pve-user@pve.proxmox.com">pve-user@pve.proxmox.com</a>
<a class="moz-txt-link-freetext" href="http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user">http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user</a>
</pre>
</blockquote>
<br>
</body>
</html>