From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id B44F5601A8 for ; Tue, 1 Dec 2020 09:24:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A3C22E406 for ; Tue, 1 Dec 2020 09:24:26 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 22AE8E3F5 for ; Tue, 1 Dec 2020 09:24:26 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E564144226 for ; Tue, 1 Dec 2020 09:24:25 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 1 Dec 2020 09:24:20 +0100 Message-Id: <20201201082421.4646-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201201082421.4646-1-f.ebner@proxmox.com> References: <20201201082421.4646-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.009 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [vzdump.pm] Subject: [pve-devel] [PATCH manager 3/4] vzdump: convert maxfiles CLI parameter to prune-backups X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Dec 2020 08:24:26 -0000 in preparation to clean up handling in new(). Signed-off-by: Fabian Ebner --- PVE/VZDump.pm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 94aa76ab..8574fc94 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -69,6 +69,29 @@ sub run_command { PVE::Tools::run_command($cmdstr, %param, logfunc => $logfunc); } +my $parse_prune_backups_maxfiles = sub { + my ($param, $kind) = @_; + + my $maxfiles = delete $param->{maxfiles}; + my $prune_backups = $param->{'prune-backups'}; + + warn "both 'maxfiles' and 'prune-backups' defined as ${kind} - ignoring 'maxfiles'\n" + if defined($maxfiles) && defined($prune_backups); + + if (defined($prune_backups)) { + $param->{'prune-backups'} = PVE::JSONSchema::parse_property_string( + 'prune-backups', + $prune_backups + ); + } elsif (defined($maxfiles)) { + if ($maxfiles) { + $param->{'prune-backups'} = { 'keep-last' => $maxfiles }; + } else { + $param->{'prune-backups'} = { 'keep-all' => 1 }; + } + } +}; + sub storage_info { my $storage = shift; @@ -1170,8 +1193,7 @@ sub verify_vzdump_parameters { raise_param_exc({ 'prune-backups' => "option conflicts with option 'maxfiles'"}) if defined($param->{'prune-backups'}) && defined($param->{maxfiles}); - $param->{'prune-backups'} = PVE::JSONSchema::parse_property_string('prune-backups', $param->{'prune-backups'}) - if defined($param->{'prune-backups'}); + $parse_prune_backups_maxfiles->($param, 'CLI parameters'); $param->{all} = 1 if (defined($param->{exclude}) && !$param->{pool}); -- 2.20.1