From 6d89b548e13fddb185aff28387054a9ead24def2 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 7 Jan 2015 08:31:32 +0100 Subject: [PATCH] add optionnal current param to config api config api return by default the pending config, like this it don't break current behaviour Add an optionnal current param to get to current running config Signed-off-by: Alexandre Derumier Signed-off-by: Dietmar Maurer --- PVE/API2/Qemu.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 68899d8..7919576 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -662,6 +662,12 @@ __PACKAGE__->register_method({ properties => { node => get_standard_option('pve-node'), vmid => get_standard_option('pve-vmid'), + current => { + description => "Get current values (instead of pending values).", + optional => 1, + default => 0, + type => 'boolean', + }, }, }, returns => { @@ -679,6 +685,19 @@ __PACKAGE__->register_method({ my $conf = PVE::QemuServer::load_config($param->{vmid}); delete $conf->{snapshots}; + + 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; + } + foreach my $opt (PVE::Tools::split_list($conf->{pending}->{delete})) { + delete $conf->{$opt} if $conf->{$opt}; + } + } + delete $conf->{pending}; return $conf; -- 2.39.2