<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<br>
<div class="moz-cite-prefix">On 02/05/2016 04:46 PM, Mohamed Sadok
Ben Jazia wrote:<br>
</div>
<blockquote
cite="mid:CAKATEKj753q7ErqjPF+P6ciKhQOPWgsfSY7bSQx75DkCwG+0kw@mail.gmail.com"
type="cite">
<div dir="ltr">I think those last lines are good for my work
<div>
<blockquote type="cite" style="font-size:12.8px">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')<br>
<br>
<br>
</blockquote>
</div>
</div>
</blockquote>
<div>
<blockquote type="cite" style="font-size:12.8px">Do you think
proxmox server can support a lot of pings each a short period of
time?</blockquote>
</div>
<br>
Proxmox normally for sure, your network on the other side may be
less (latency wise).<br>
<br>
As "worker" normally will be used for longer running tasks (a few
seconds to a few minutes, depends on the action and hardware) i
think polling once per second should be fast enough enough, and that
is surely hand-able by PVE.<br>
<br>
<br>
<br>
<blockquote
cite="mid:CAKATEKj753q7ErqjPF+P6ciKhQOPWgsfSY7bSQx75DkCwG+0kw@mail.gmail.com"
type="cite">
<div class="gmail_extra">
<div class="gmail_quote">On 5 February 2016 at 15:34, Thomas
Lamprecht <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:t.lamprecht@proxmox.com" target="_blank">t.lamprecht@proxmox.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div 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 moz-do-not-send="true"
href="https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/Tools.pm;h=9f08aa6fbf0c08da62e2f17078684cc2136d5b14;hb=HEAD#l854"
target="_blank">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 moz-do-not-send="true"
href="https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/ProcFSTools.pm;h=516c0e8b939791a64771df41c36df362e65c7423;hb=HEAD#l355"
target="_blank">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>
<div>
<div class="h5"> <br>
<br>
<br>
<div>On 02/05/2016 02:09 PM, Mohamed Sadok Ben Jazia
wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<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></fieldset>
<br>
</div>
</div>
<pre>_______________________________________________
pve-user mailing list
<a moz-do-not-send="true" href="mailto:pve-user@pve.proxmox.com" target="_blank">pve-user@pve.proxmox.com</a>
<a moz-do-not-send="true" href="http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user" target="_blank">http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user</a>
</pre>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
pve-user mailing list<br>
<a moz-do-not-send="true"
href="mailto:pve-user@pve.proxmox.com">pve-user@pve.proxmox.com</a><br>
<a moz-do-not-send="true"
href="http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user"
rel="noreferrer" target="_blank">http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user</a><br>
<br>
</blockquote>
</div>
<br>
</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>