[pve-devel] [RFC firewall] api: Add optional parameters `since` and `until` for timestamp filter

Fiona Ebner f.ebner at proxmox.com
Thu Jan 5 14:51:07 CET 2023


Just two refreshers about style ;)

Am 05.01.23 um 10:18 schrieb Christian Ebner:
> The optional unix epoch timestamps parameters `since` and `until` are introduced in order to filter
> firewall logs files.
> 
> Since the `dump_logfile` function is used in multiple places, not neccessarily following the firewall
> log output format, a specialized function `dump_fw_logfile` is introduced in the PVE::Tools,
> with fallback to the previous `dump_logfile` function if none of the parameters is present.
> 
> This patch depends on the corresponding patch in the pve-common repository.
> 

Style nit: lines in the commit message should be <= 70 characters [0]

> @@ -197,7 +209,8 @@ __PACKAGE__->register_method({
>  	my $user = $rpcenv->get_user();
>  	my $node = $param->{node};
>  
> -	my ($count, $lines) = PVE::Tools::dump_logfile("/var/log/pve-firewall.log", $param->{start}, $param->{limit});
> +	my($count, $lines) = PVE::Tools::dump_fw_logfile("/var/log/pve-firewall.log",
> +		$param->{start}, $param->{limit}, undef, $param->{since}, $param->{until});

Style nit: please use 1 line for each parameter if it gets too long [1]

> @@ -201,9 +213,9 @@ sub register_handlers {
>  	    my $user = $rpcenv->get_user();
>  	    my $vmid = $param->{vmid};
>  
> -	    my ($count, $lines) = PVE::Tools::dump_logfile("/var/log/pve-firewall.log",
> -							   $param->{start}, $param->{limit},
> -							   "^$vmid ");
> +	    my ($count, $lines) = PVE::Tools::dump_fw_logfile("/var/log/pve-firewall.log",
> +		$param->{start}, $param->{limit}, "^$vmid ", $param->{since},
> +		$param->{until});

Same here

[0]:
https://pve.proxmox.com/wiki/Developer_Documentation#Commits_and_Commit_Messages
[1]: https://pve.proxmox.com/wiki/Perl_Style_Guide#Wrapping_Arguments





More information about the pve-devel mailing list