[pve-devel] [PATCH v2 container 11/18] use load_current_config for config GET call

Oguz Bektas o.bektas at proxmox.com
Mon Sep 30 14:44:43 CEST 2019


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

diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
index 769fc3b..7eaef74 100644
--- a/src/PVE/API2/LXC/Config.pm
+++ b/src/PVE/API2/LXC/Config.pm
@@ -34,6 +34,12 @@ __PACKAGE__->register_method({
 	properties => {
 	    node => get_standard_option('pve-node'),
 	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
+	    current => {
+		description => "Get current values (instead of pending values).",
+		optional => 1,
+		default => 0,
+		type => 'boolean',
+	    },
 	    snapshot => get_standard_option('pve-snapshot-name', {
 		description => "Fetch config values from given snapshot.",
 		optional => 1,
@@ -62,22 +68,10 @@ __PACKAGE__->register_method({
     code => sub {
 	my ($param) = @_;
 
-	my $conf = PVE::LXC::Config->load_config($param->{vmid});
-
-	if (my $snapname = $param->{snapshot}) {
-	    my $snapshot = $conf->{snapshots}->{$snapname};
-	    die "snapshot '$snapname' does not exist\n" if !defined($snapshot);
-
-	    # we need the digest of the file
-	    $snapshot->{digest} = $conf->{digest};
-	    $conf = $snapshot;
-	}
-
-	delete $conf->{snapshots};
-
-	return $conf;
+	return PVE::LXC::Config->load_current_config($param->{vmid}, $param->{snapshot}, $param->{current})
     }});
 
+
 my $vm_config_perm_list = [
     'VM.Config.Disk',
     'VM.Config.CPU',
-- 
2.20.1




More information about the pve-devel mailing list