Example:
    pvesh get /nodes/{node}/qemu/{vmid}/rrddata --timeframe day

If the sorting key is not defined in the dataset, e.g. when a VM was not running
for some time within the given timeframe, this resulted in several ugly 
warnings.

Signed-off-by: Christian Ebner <c.eb...@proxmox.com>
---
 src/PVE/CLIFormatter.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/PVE/CLIFormatter.pm b/src/PVE/CLIFormatter.pm
index 0e9cbe6..65802f8 100644
--- a/src/PVE/CLIFormatter.pm
+++ b/src/PVE/CLIFormatter.pm
@@ -175,9 +175,9 @@ sub print_text_table {
     if (defined($sort_key) && $sort_key ne 0) {
        my $type = $returnprops->{$sort_key}->{type} // 'string';
        if ($type eq 'integer' || $type eq 'number') {
-           @$data = sort { $a->{$sort_key} <=> $b->{$sort_key} } @$data;
+           @$data = sort { defined $a->{$sort_key} <=> defined $b->{$sort_key} 
} @$data;
        } else {
-           @$data = sort { $a->{$sort_key} cmp $b->{$sort_key} } @$data;
+           @$data = sort { defined $a->{$sort_key} cmp defined $b->{$sort_key} 
} @$data;
        }
     }
 
-- 
2.20.1

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to