[pve-devel] [PATCH v2 guest-common 03/18] refactor code from qm/pct 'pending' call into AbstractConfig

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Oct 2 11:51:32 CEST 2019


container hasn't any pending calls to factor out at this point,
subject makes no sense?

Also hows "refactor code from somwhere" a telling subject?

how about:
> helpers: add pending-aware guest config printer from qemu-server

On 9/30/19 2:44 PM, Oguz Bektas wrote:
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
>  PVE/GuestHelpers.pm | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/PVE/GuestHelpers.pm b/PVE/GuestHelpers.pm
> index ebe2781..a16433f 100644
> --- a/PVE/GuestHelpers.pm
> +++ b/PVE/GuestHelpers.pm
> @@ -60,4 +60,30 @@ sub exec_hookscript {
>      }
>  }
>  
> +sub format_pending {
> +    my ($data) = @_;

add new line here

> +    foreach my $item (sort { $a->{key} cmp $b->{key}} @$data) {
> +	my $k = $item->{key};
> +	next if $k eq 'digest';
> +	my $v = $item->{value};
> +	my $p = $item->{pending};

newline here and while I now that the origin of this in the qm CLI
module uses the same variable names, I'd still do:

s/k/key/
s/v/value/
s/p/pending/

> +	if ($k eq 'description') {
> +	    $v = PVE::Tools::encode_text($v) if defined($v);
> +	    $p = PVE::Tools::encode_text($p) if defined($p);
> +	}
> +	if (defined($v)) {
> +	    if ($item->{delete}) {
> +		print "del $k: $v\n";
> +	    } elsif (defined($p)) {
> +		print "cur $k: $v\n";
> +		print "new $k: $p\n";
> +	    } else {
> +		print "cur $k: $v\n";
> +	    }
> +	} elsif (defined($p)) {
> +	    print "new $k: $p\n";
> +	}
> +    }
> +}
> +
>  1;
> 





More information about the pve-devel mailing list