]> git.proxmox.com Git - pve-manager.git/commitdiff
add task list/log/status to pvenode
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 29 Jun 2018 08:20:22 +0000 (10:20 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 29 Jun 2018 08:31:23 +0000 (10:31 +0200)
and use the newly created print_api_* helpers for this

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/CLI/pvenode.pm

index cf687666f9a76e652f24530a6876b84ed7a8cfab..7c0f7b64f87728e393b4d77d6ae615c419e31247 100644 (file)
@@ -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 {