]> git.proxmox.com Git - pve-common.git/commitdiff
PVE::CLIHandler::print_api_list - use all occuring properties
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 22 Jun 2018 18:21:07 +0000 (20:21 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 25 Jun 2018 10:09:42 +0000 (12:09 +0200)
print_api_list falls back to the union of all properties occuring in data, if
none are provided explicitly, and the API method contains no returns property.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PVE/CLIHandler.pm

index b04326f4ba2cf322b520761c3580485e240b53d4..569f5903b47498c5dd4f1da9fde1e287596cd4f6 100644 (file)
@@ -510,7 +510,13 @@ sub print_api_list {
     if (!defined($props_to_print)) {
        $props_to_print = [ sort keys %$returnprops ];
        if (!scalar(@$props_to_print)) {
     if (!defined($props_to_print)) {
        $props_to_print = [ sort keys %$returnprops ];
        if (!scalar(@$props_to_print)) {
-           $props_to_print = [ sort keys %{$data->[0]} ];
+           my $all_props = {};
+           foreach my $obj (@{$data}) {
+               foreach my $key (keys %{$obj}) {
+                   $all_props->{ $key } = 1;
+               }
+           }
+           $props_to_print = [ sort keys %{$all_props} ];
        }
        die "unable to detect list properties\n" if !scalar(@$props_to_print);
     }
        }
        die "unable to detect list properties\n" if !scalar(@$props_to_print);
     }