[pve-devel] [PATCH manager 4/5] add task list/log/status to pvenode

Dominik Csapak d.csapak at proxmox.com
Wed Jun 27 14:06:18 CEST 2018


and use the newly created print_api_* helpers for this

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/CLI/pvenode.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/PVE/CLI/pvenode.pm b/PVE/CLI/pvenode.pm
index cf687666..f5ccdd71 100644
--- a/PVE/CLI/pvenode.pm
+++ b/PVE/CLI/pvenode.pm
@@ -8,6 +8,7 @@ use PVE::API2::ACMEAccount;
 use PVE::API2::Certificates;
 use PVE::API2::NodeConfig;
 use PVE::API2::Nodes;
+use PVE::API2::Tasks;
 
 use PVE::CertHelpers;
 use PVE::Certificate;
@@ -179,6 +180,29 @@ our $cmddef = {
 	delete => [ 'PVE::API2::Certificates', 'remove_custom_cert', ['restart'], { node => $nodename } ],
     },
 
+    task => {
+	list => [ 'PVE::API2::Tasks', 'node_tasks', [], { node => $nodename }, sub {
+	    my ($data, $resultprops) = @_;
+	    foreach my $task (@$data) {
+		if ($task->{status} ne 'OK') {
+		    $task->{status} = 'ERROR';
+		}
+	    }
+	    PVE::CLIHandler::print_api_list($data, $resultprops, ['upid', 'type', 'id', 'user', 'starttime', 'endtime', 'status' ], 0);
+	}],
+	status => [ 'PVE::API2::Tasks', 'read_task_status', [ 'upid' ], { node => $nodename }, sub {
+	    my ($data, $resultprops) = @_;
+	    PVE::CLIHandler::print_api_result('text', $data, $resultprops);
+	}],
+	# set limit to 1000000, so we see the whole log, not only the first 50 lines by default
+	log => [ 'PVE::API2::Tasks', 'read_task_log', [ 'upid' ], { node => $nodename, limit => 1000000 }, sub {
+	    my ($data, $resultprops) = @_;
+	    foreach my $line (@$data) {
+		print $line->{t} . "\n";
+	    }
+	}],
+    },
+
     acme => {
 	account => {
 	    list => [ 'PVE::API2::ACMEAccount', 'account_index', [], {}, sub {
-- 
2.11.0





More information about the pve-devel mailing list