From: Dietmar Maurer Date: Fri, 5 May 2017 08:54:10 +0000 (+0200) Subject: PVE::API2::Storage::Replication->jobs(): return array X-Git-Url: https://git.proxmox.com/?p=pve-storage.git;a=commitdiff_plain;h=339ca30a5b09055358dc1b857324f23883ef8b75 PVE::API2::Storage::Replication->jobs(): return array --- diff --git a/PVE/API2/Storage/Replication.pm b/PVE/API2/Storage/Replication.pm index 9123f22..ab52b01 100644 --- a/PVE/API2/Storage/Replication.pm +++ b/PVE/API2/Storage/Replication.pm @@ -55,11 +55,20 @@ __PACKAGE__->register_method ({ node => get_standard_option('pve-node'), }, }, - returns => { type => 'object' }, + returns => { + type => 'array', + items => { + type => "object", + properties => {}, + }, + links => [ { rel => 'child', href => "{vmid}" } ], + }, code => sub { my ($param) = @_; - return PVE::ReplicationTools::get_all_jobs(); + my $jobs = PVE::ReplicationTools::get_all_jobs(); + + return PVE::RESTHandler::hash_to_array($jobs, 'vmid'); }}); 1; diff --git a/PVE/CLI/pvesr.pm b/PVE/CLI/pvesr.pm index 0f4f5c7..72b18e5 100644 --- a/PVE/CLI/pvesr.pm +++ b/PVE/CLI/pvesr.pm @@ -22,16 +22,16 @@ sub setup_environment { } my $print_job_list = sub { - my ($conf) = @_; + my ($list) = @_; printf("%-10s%-20s%-20s%-5s%-10s%-5s\n", "VMID", "DEST", "LAST SYNC","IVAL", "STATE", "FAIL"); - foreach my $vmid (sort keys %$conf) { - my $job = $conf->{$vmid}; + foreach my $job (sort { $a->{vmid} <=> $b->{vmid} } @$list) { + my $timestr = strftime("%Y-%m-%d_%H:%M:%S", localtime($job->{lastsync})); - printf("%-9s ", $vmid); + printf("%-9s ", $job->{vmid}); printf("%-19s ", $job->{tnode}); printf("%-19s ", $timestr); printf("%-4s ", $job->{interval});