]> git.proxmox.com Git - pve-storage.git/commitdiff
prune-backups CLI: use keep-options directly
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 31 Aug 2020 08:48:01 +0000 (10:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 3 Sep 2020 16:20:06 +0000 (18:20 +0200)
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>
PVE/CLI/pvesm.pm
PVE/Storage/Plugin.pm

index caac51bed58c5e599b4d1724d024694eecbb72bc..d7591eec5b9fd4226b1a537adf891e1c4a98a637 100755 (executable)
@@ -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);
index 8a58ff4050ae516af4ffe708a196e8bf274a704a..5b337df10a54dda18d6d45b69c960b91fa5d766e 100644 (file)
@@ -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 <N> backups.',