Signed-off-by: Tim Marx <t.m...@proxmox.com> --- PVE/GuestHelpers.pm | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
diff --git a/PVE/GuestHelpers.pm b/PVE/GuestHelpers.pm index 1688c5c..176d903 100644 --- a/PVE/GuestHelpers.pm +++ b/PVE/GuestHelpers.pm @@ -205,19 +205,29 @@ sub format_pending { # value (the current value in effect - if any) # pending (a new, still pending, value - if any) # delete (when deletions are pending, this is set to either 2 (force) or 1 (graceful)) -sub config_with_pending_array { - my ($conf, $pending_delete_hash) = @_; +sub config_with_pending { + my ($conf, $pending_delete_hash, $asObject) = @_; my $res = []; + if ($asObject) { + $res = {}; + } + foreach my $opt (keys %$conf) { next if ref($conf->{$opt}); my $item = { key => $opt }; + if ($asObject) { + $item = {}; + } $item->{value} = $conf->{$opt} if defined($conf->{$opt}); $item->{pending} = $conf->{pending}->{$opt} if defined($conf->{pending}->{$opt}); $item->{delete} = ($pending_delete_hash->{$opt}->{force} ? 2 : 1) if exists $pending_delete_hash->{$opt}; - - push @$res, $item; + if ($asObject) { + $res->{$opt} = $item; + } else { + push @$res, $item; + } } foreach my $opt (keys %{$conf->{pending}}) { @@ -225,16 +235,28 @@ sub config_with_pending_array { next if ref($conf->{pending}->{$opt}); # just to be sure next if defined($conf->{$opt}); my $item = { key => $opt }; + if ($asObject) { + $item = {}; + } $item->{pending} = $conf->{pending}->{$opt}; - push @$res, $item; + if ($asObject) { + $res->{$opt} = $item; + } else { + push @$res, $item; + } } while (my ($opt, $force) = each %$pending_delete_hash) { next if $conf->{pending}->{$opt}; # just to be sure next if $conf->{$opt}; my $item = { key => $opt, delete => ($force ? 2 : 1)}; - push @$res, $item; + if ($asObject) { + $res->{$opt} = $item; + } else { + $item->{key} = $opt; + push @$res, $item; + } } return $res; -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel