[pve-devel] [PATCH pve-client v2 2/2] Add task log to 'lxc create'

René Jochum r.jochum at proxmox.com
Tue Jun 19 17:45:32 CEST 2018


---
 PVE/APIClient/Commands/lxc.pm |  2 ++
 PVE/APIClient/Helpers.pm      | 15 +++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm
index 2309ec0..db618e7 100644
--- a/PVE/APIClient/Commands/lxc.pm
+++ b/PVE/APIClient/Commands/lxc.pm
@@ -446,6 +446,8 @@ __PACKAGE__->register_method ({
 
 	print PVE::APIClient::Helpers::poll_task($conn, $node, $upid) . "\n";
 
+	print PVE::APIClient::Helpers::get_task_log($conn, $node, $upid) . "\n";
+
 	return undef;
     }});
 
diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
index 30b8475..606561a 100644
--- a/PVE/APIClient/Helpers.pm
+++ b/PVE/APIClient/Helpers.pm
@@ -339,6 +339,21 @@ sub poll_task {
     return $task_status->{exitstatus};
 }
 
+sub get_task_log {
+    my ($conn, $node, $upid) = @_;
+
+    my $path = "api2/json/nodes/$node/tasks/$upid/log";
+
+    my $task_log = $conn->get($path, {});
+
+    my $result = "";
+    for my $li (@$task_log) {
+	$result .= $li->{t} . "\n";
+    }
+
+    return $result;
+}
+
 sub configuration_directory {
 
     my $home = $ENV{HOME} // '';
-- 
2.11.0



More information about the pve-devel mailing list