[pve-devel] [PATCH qemu-server] api: add option to get pending config returned as object instead of an array

Tim Marx t.marx at proxmox.com
Wed May 20 14:23:43 CEST 2020


Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
 PVE/API2/Qemu.pm | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index fd51bf3..0b31f53 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -940,14 +940,20 @@ __PACKAGE__->register_method({
 	check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
     },
     parameters => {
-	additionalProperties => 0,
 	properties => {
 	    node => get_standard_option('pve-node'),
 	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::QemuServer::complete_vmid }),
+	    object => {
+		description => "In this case the root element is an object instead of an array.".
+			       "The key property of the items will be extracted and used as the root object keys.",
+		optional => 1,
+		default => 0,
+		type => 'boolean',
+	    },
 	},
     },
     returns => {
-	type => "array",
+	type => [ "array", "object"],
 	items => {
 	    type => "object",
 	    properties => {
@@ -985,8 +991,7 @@ __PACKAGE__->register_method({
 
 	$conf->{cipassword} = '**********' if defined($conf->{cipassword});
 	$conf->{pending}->{cipassword} = '********** ' if defined($conf->{pending}->{cipassword});
-
-	return PVE::GuestHelpers::config_with_pending_array($conf, $pending_delete_hash);
+	return PVE::GuestHelpers::config_with_pending($conf, $pending_delete_hash, $param->{object});
    }});
 
 # POST/PUT {vmid}/config implementation
-- 
2.20.1




More information about the pve-devel mailing list