[pve-devel] [PATCH common 2/3] PVE::CLIHandler::print_api_list - use all occuring properties

Stoiko Ivanov s.ivanov at proxmox.com
Fri Jun 22 20:21:07 CEST 2018


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 at proxmox.com>
---
 src/PVE/CLIHandler.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
index b04326f..569f590 100644
--- a/src/PVE/CLIHandler.pm
+++ b/src/PVE/CLIHandler.pm
@@ -510,7 +510,13 @@ sub print_api_list {
     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);
     }
-- 
2.11.0




More information about the pve-devel mailing list