prune-backups CLI: use keep-options directly
Makes the interface cleaner; e.g. --keep-daily=2 instead of --prune-backups=keep-daily=2 Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
c3e87d0f6e
commit
a0933d7e16
@ -752,10 +752,7 @@ __PACKAGE__->register_method ({
|
|||||||
storage => get_standard_option('pve-storage-id', {
|
storage => get_standard_option('pve-storage-id', {
|
||||||
completion => \&PVE::Storage::complete_storage_enabled,
|
completion => \&PVE::Storage::complete_storage_enabled,
|
||||||
}),
|
}),
|
||||||
'prune-backups' => get_standard_option('prune-backups', {
|
%{$PVE::Storage::Plugin::prune_backups_format},
|
||||||
description => "Use these retention options instead of those from the storage configuration.",
|
|
||||||
optional => 1,
|
|
||||||
}),
|
|
||||||
type => {
|
type => {
|
||||||
description => "Either 'qemu' or 'lxc'. Only consider backups for guests of this type.",
|
description => "Either 'qemu' or 'lxc'. Only consider backups for guests of this type.",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
@ -813,6 +810,13 @@ __PACKAGE__->register_method ({
|
|||||||
|
|
||||||
my $dryrun = extract_param($param, 'dry-run') ? 1 : 0;
|
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 = [];
|
my $list = [];
|
||||||
if ($dryrun) {
|
if ($dryrun) {
|
||||||
$list = PVE::API2::Storage::PruneBackups->dryrun($param);
|
$list = PVE::API2::Storage::PruneBackups->dryrun($param);
|
||||||
|
|||||||
@ -49,7 +49,7 @@ my %prune_option = (
|
|||||||
format_description => 'N',
|
format_description => 'N',
|
||||||
);
|
);
|
||||||
|
|
||||||
my $prune_backups_format = {
|
our $prune_backups_format = {
|
||||||
'keep-last' => {
|
'keep-last' => {
|
||||||
%prune_option,
|
%prune_option,
|
||||||
description => 'Keep the last <N> backups.',
|
description => 'Keep the last <N> backups.',
|
||||||
|
|||||||
Reference in New Issue
Block a user