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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 9F36269571 for ; Mon, 31 Aug 2020 10:48:09 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 922C911FD0 for ; Mon, 31 Aug 2020 10:48:09 +0200 (CEST) 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 D514C11FC0 for ; Mon, 31 Aug 2020 10:48:08 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A9CD544970 for ; Mon, 31 Aug 2020 10:48:08 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Mon, 31 Aug 2020 10:48:01 +0200 Message-Id: <20200831084802.25887-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.052 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. [pvesm.pm, plugin.pm] Subject: [pve-devel] [PATCH storage 1/2] prune-backups CLI: use keep-options directly 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: Mon, 31 Aug 2020 08:48:09 -0000 Makes the interface cleaner; e.g. --keep-daily=2 instead of --prune-backups=keep-daily=2 Signed-off-by: Fabian Ebner --- PVE/CLI/pvesm.pm | 12 ++++++++---- PVE/Storage/Plugin.pm | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PVE/CLI/pvesm.pm b/PVE/CLI/pvesm.pm index caac51b..d7591ee 100755 --- a/PVE/CLI/pvesm.pm +++ b/PVE/CLI/pvesm.pm @@ -752,10 +752,7 @@ __PACKAGE__->register_method ({ storage => get_standard_option('pve-storage-id', { completion => \&PVE::Storage::complete_storage_enabled, }), - 'prune-backups' => get_standard_option('prune-backups', { - description => "Use these retention options instead of those from the storage configuration.", - optional => 1, - }), + %{$PVE::Storage::Plugin::prune_backups_format}, type => { description => "Either 'qemu' or 'lxc'. Only consider backups for guests of this type.", type => 'string', @@ -813,6 +810,13 @@ __PACKAGE__->register_method ({ my $dryrun = extract_param($param, 'dry-run') ? 1 : 0; + my $keep_opts; + foreach my $keep (keys %{$PVE::Storage::Plugin::prune_backups_format}) { + $keep_opts->{$keep} = extract_param($param, $keep) if defined($param->{$keep}); + } + $param->{'prune-backups'} = PVE::JSONSchema::print_property_string( + $keep_opts, $PVE::Storage::Plugin::prune_backups_format) if $keep_opts; + my $list = []; if ($dryrun) { $list = PVE::API2::Storage::PruneBackups->dryrun($param); diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 8a58ff4..5b337df 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -49,7 +49,7 @@ my %prune_option = ( format_description => 'N', ); -my $prune_backups_format = { +our $prune_backups_format = { 'keep-last' => { %prune_option, description => 'Keep the last backups.', -- 2.20.1