X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FHelpers.pm;h=7d855ec6ce58fc6775569fbb426c364dcc3f58bf;hp=30b847533564d0240c15831173dee9d73c4f36fb;hb=2b267ba22efefb08ac15feac1107b920f6186f50;hpb=b7db4587c1182e5f347b4476b8e8b141049f3f3e diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm index 30b8475..7d855ec 100644 --- a/PVE/APIClient/Helpers.pm +++ b/PVE/APIClient/Helpers.pm @@ -321,19 +321,38 @@ sub get_vmid_resource { } sub poll_task { - my ($conn, $node, $upid) = @_; + my ($conn, $node, $upid, $quiet) = @_; my $path = "api2/json/nodes/$node/tasks/$upid/status"; my $task_status; + my $last_line = 0; while(1) { + if (!$quiet) { + my $path = "api2/json/nodes/$node/tasks/$upid/log"; + my $task_log = $conn->get($path, {start => $last_line}); + + my $printme = ''; + for my $li (@$task_log) { + if ($li->{t} eq 'no content') { + next; + } + $printme .= $li->{t} . "\n"; + $last_line = $li->{n}; + } + + if ($printme ne '') { + print $printme; + } + } + $task_status = $conn->get($path, {}); if ($task_status->{status} eq "stopped") { last; } - sleep(10); + sleep(2); } return $task_status->{exitstatus};