you completely ignored my comments for v1 of this patch? the whole code is identical to qemu-server's, except for cipassword handling. pending changes are also encoded identically for both pve-container and qemu-server, so it makes sense to move this to AbstractConfig or GuestHelpers.pm with an override for cipassword in QemuConfig.pm/here..
this basically just converts $conf into a different representation for easier client consumption.. On September 30, 2019 2:44 pm, Oguz Bektas wrote: > Signed-off-by: Oguz Bektas <o.bek...@proxmox.com> > --- > src/PVE/API2/LXC.pm | 88 +++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 88 insertions(+) > > diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm > index 07280fb..9c040d1 100644 > --- a/src/PVE/API2/LXC.pm > +++ b/src/PVE/API2/LXC.pm > @@ -515,6 +515,7 @@ __PACKAGE__->register_method({ > > my $res = [ > { subdir => 'config' }, > + { subdir => 'pending' }, > { subdir => 'status' }, > { subdir => 'vncproxy' }, > { subdir => 'termproxy' }, > @@ -1865,4 +1866,91 @@ __PACKAGE__->register_method({ > return $task; > }}); > > +__PACKAGE__->register_method({ > + name => 'vm_pending', > + path => '{vmid}/pending', > + method => 'GET', > + proxyto => 'node', > + description => 'Get container configuration, including pending changes.', > + permissions => { > + check => ['perm', '/vms/{vmid}', [ 'VM.Audit' ]], > + }, > + parameters => { > + additionalProperties => 0, > + properties => { > + node => get_standard_option('pve-node'), > + vmid => get_standard_option('pve-vmid', { completion => > \&PVE::LXC::complete_ctid }), > + }, > + }, > + returns => { > + type => "array", > + items => { > + type => "object", > + properties => { > + key => { > + description => 'Configuration option name.', > + type => 'string', > + }, > + value => { > + description => 'Current value.', > + type => 'string', > + optional => 1, > + }, > + pending => { > + description => 'Pending value.', > + type => 'string', > + optional => 1, > + }, > + delete => { > + description => "Indicates a pending delete request if > present and not 0.", > + type => 'integer', > + minimum => 0, > + maximum => 1, > + optional => 1, > + }, > + }, > + }, > + }, > + code => sub { > + my ($param) = @_; > + > + my $conf = PVE::LXC::Config->load_config($param->{vmid}); > + > + my $pending_delete_hash = > PVE::LXC::Config->parse_pending_delete($conf->{pending}->{delete}); > + > + my $res = []; > + > + foreach my $opt (keys %$conf) { > + next if ref($conf->{$opt}); > + next if $opt eq 'pending'; > + my $item = { key => $opt } ; > + $item->{value} = $conf->{$opt} if defined($conf->{$opt}); > + $item->{pending} = $conf->{pending}->{$opt} if > defined($conf->{pending}->{$opt}); > + $item->{delete} = ($pending_delete_hash->{$opt} ? 2 : 1) if exists > $pending_delete_hash->{$opt}; > + > + push @$res, $item; > + } > + > + foreach my $opt (keys %{$conf->{pending}}) { > + next if $opt eq 'delete'; > + next if ref($conf->{pending}->{$opt}); > + next if defined($conf->{$opt}); > + my $item = { key => $opt }; > + $item->{pending} = $conf->{pending}->{$opt}; > + > + push @$res, $item; > + } > + > + # FIXME: $force delete is not implemented for CTs > + while (my ($opt, undef) = each %$pending_delete_hash) { > + next if $conf->{pending}->{$opt}; > + next if $conf->{$opt}; > + my $item = { key => $opt, delete => 1 }; > + push @$res, $item; > + } > + > + return $res; > + > + }}); > + > 1; > -- > 2.20.1 > > _______________________________________________ > pve-devel mailing list > pve-devel@pve.proxmox.com > https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel