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

Dominik Csapak d.csapak at proxmox.com
Fri Jun 29 10:20:22 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 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/PVE/CLI/pvenode.pm b/PVE/CLI/pvenode.pm
index cf687666..7c0f7b64 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;
@@ -15,6 +16,7 @@ use PVE::Exception qw(raise_param_exc raise);
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::NodeConfig;
 use PVE::RPCEnvironment;
+use PVE::CLIFormatter;
 
 use Term::ReadLine;
 
@@ -179,6 +181,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::CLIFormatter::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::CLIFormatter::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