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

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Oct 2 12:30:47 CEST 2019


subject proposal:
> api: config: add 'current' param to get config without pending changes

commit message:
> container can now also have pending changes, thus we want to have a method
> to get the current applied config and the one with pending changes. This
> makes the GET config API more consistent with the qemu-server one by reusing
> the load_current_config through the AbstractConfig interface.

On 9/30/19 2:44 PM, Oguz Bektas wrote:
> 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',
> 





More information about the pve-devel mailing list