[pve-devel] [PATCH 2/5] add pending param to config api

Alexandre Derumier aderumier at odiso.com
Mon Dec 29 14:30:42 CET 2014


return the config when pending changes applied

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm |   27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index fb36ce8..4467837 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -624,7 +624,7 @@ __PACKAGE__->register_method({
     path => '{vmid}/config',
     method => 'GET',
     proxyto => 'node',
-    description => "Get current virtual machine configuration. This does not include pending configuration changes (see 'pending' API).",
+    description => "Get current virtual machine configuration",
     permissions => {
 	check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]],
     },
@@ -633,6 +633,11 @@ __PACKAGE__->register_method({
 	properties => {
 	    node => get_standard_option('pve-node'),
 	    vmid => get_standard_option('pve-vmid'),
+            pending => {
+                optional => 1,
+                type => 'boolean',
+                description => "Get pending values instead running values",
+            },
 	},
     },
     returns => {
@@ -650,6 +655,17 @@ __PACKAGE__->register_method({
 	my $conf = PVE::QemuServer::load_config($param->{vmid});
 
 	delete $conf->{snapshots};
+
+	if($param->{pending}){
+	    foreach my $opt (keys $conf->{pending}) {
+		foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) {
+		    delete $conf->{$opt} if $conf->{$opt};
+		}
+		next if ref($conf->{pending}->{$opt}); # just to be sure
+		$conf->{$opt} = $conf->{pending}->{$opt};
+	    }
+	}
+
 	delete $conf->{pending};
 
 	return $conf;
@@ -1113,6 +1129,10 @@ __PACKAGE__->register_method({
 		    maximum => 30,
 		    optional => 1,
 		},
+		pending => {
+		    optional => 1,
+		    type => 'boolean',
+		}
 	    }),
     },
     returns => {
@@ -1156,6 +1176,10 @@ __PACKAGE__->register_method({
 		    maxLength => 40,
 		    optional => 1,
 		},
+		pending => {
+		    optional => 1,
+		    type => 'boolean',
+		}
 	    }),
     },
     returns => { type => 'null' },
@@ -1166,7 +1190,6 @@ __PACKAGE__->register_method({
     }
 });
 
-
 __PACKAGE__->register_method({
     name => 'destroy_vm',
     path => '{vmid}',
-- 
1.7.10.4




More information about the pve-devel mailing list