[pve-devel] [PATCH common 04/10] PBSClient: allow different command execution callback

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Apr 21 15:19:43 CEST 2021


On April 21, 2021 1:15 pm, Stefan Reiter wrote:
> do_raw_client_cmd gains a parameter which it calls instead of
> run_command at the end. While at it, rename it to run_raw_client_cmd, as
> the current run_raw_client_cmd simply calls do_raw_client_cmd anyway.
> 
> Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
> ---
>  src/PVE/PBSClient.pm | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/src/PVE/PBSClient.pm b/src/PVE/PBSClient.pm
> index c3bfab7..f6b46b2 100644
> --- a/src/PVE/PBSClient.pm
> +++ b/src/PVE/PBSClient.pm
> @@ -134,7 +134,7 @@ my $USE_CRYPT_PARAMS = {
>      'upload-log' => 1,
>  };
>  
> -my sub do_raw_client_cmd {
> +my sub run_raw_client_cmd {
>      my ($self, $client_cmd, $param, %opts) = @_;
>  
>      my $use_crypto = $USE_CRYPT_PARAMS->{$client_cmd};
> @@ -185,12 +185,11 @@ my sub do_raw_client_cmd {
>  	$logfunc->("run: " . join(' ', @$cmd));
>      }
>  
> -    run_command($cmd, %opts);
> -}
> -
> -my sub run_raw_client_cmd {
> -    my ($self, $client_cmd, $param, %opts) = @_;
> -    return do_raw_client_cmd($self, $client_cmd, $param, %opts);
> +    if(my $startcmd = delete $opts{startcmd}) {
> +	return $startcmd->($cmd, %opts);
> +    } else {
> +	return run_command($cmd, %opts);

I am not sure why this is needed? the only user for this has a 
$startcmd that is just a wrapper around run_command with options set, so 
it could just as well just pass these options to run_raw_client_cmd?

> +    }
>  }
>  
>  my sub run_client_cmd {
> @@ -206,7 +205,7 @@ my sub run_client_cmd {
>  
>      $param = [@$param, '--output-format=json'] if !$no_output;
>  
> -    do_raw_client_cmd(
> +    run_raw_client_cmd(
>  	$self,
>  	$client_cmd,
>  	$param,
> -- 
> 2.20.1
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 





More information about the pve-devel mailing list