[pve-devel] [PATCH container 2/9] adapt config GET call for taking pending changes

Oguz Bektas o.bektas at proxmox.com
Thu Sep 5 16:11:14 CEST 2019


the default behaviour is the same as in Qemu, so without the 'current'
flag set, current values will be replaced with their respective pending
counterparts.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 src/PVE/API2/LXC/Config.pm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
index 769fc3b..6e67186 100644
--- a/src/PVE/API2/LXC/Config.pm
+++ b/src/PVE/API2/LXC/Config.pm
@@ -53,6 +53,12 @@ __PACKAGE__->register_method({
 		items => { type => 'array', items => { type => 'string' }},
 		optional => 1,
 	    },
+	    current => {
+		description => "Get current values (instead of pending values).",
+		optional => 1,
+		default => 0,
+		type => 'boolean',
+	    },
 	    digest => {
 		type => 'string',
 		description => 'SHA1 digest of configuration file. This can be used to prevent concurrent modifications.',
@@ -73,11 +79,28 @@ __PACKAGE__->register_method({
 	    $conf = $snapshot;
 	}
 
+	# take pending changes in
+	if (!$param->{current}) {
+	    foreach my $opt (keys %{$conf->{pending}}) {
+		next if $opt eq 'delete';
+		my $value = $conf->{pending}->{$opt};
+		next if ref($value); # just to be sure
+		$conf->{$opt} = $value;
+	    }
+	    my $pending_delete_hash = PVE::LXC::Config->split_flagged_list($conf->{pending}->{delete});
+	    foreach my $opt (keys %$pending_delete_hash) {
+		delete $conf->{$opt} if $conf->{$opt};
+	    }
+	}
+
+
 	delete $conf->{snapshots};
+	delete $conf->{pending};
 
 	return $conf;
     }});
 
+
 my $vm_config_perm_list = [
     'VM.Config.Disk',
     'VM.Config.CPU',
-- 
2.20.1




More information about the pve-devel mailing list