]> git.proxmox.com Git - qemu-server.git/commitdiff
add optionnal current param to config api
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 7 Jan 2015 07:31:32 +0000 (08:31 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 7 Jan 2015 07:31:32 +0000 (08:31 +0100)
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 <aderumier@odiso.com>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
PVE/API2/Qemu.pm

index 68899d8c8f55f42dad79268537a77b27db21974f..79195761a12aa37ee8c8b2a80005008cf7ee3a5e 100644 (file)
@@ -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;