]> git.proxmox.com Git - pve-storage.git/commitdiff
import: add -delete-snapshot parameter
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 23 May 2017 10:30:18 +0000 (12:30 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 23 May 2017 11:29:48 +0000 (13:29 +0200)
This deletes a snapshot on *success*, done directly in the
CLI handler, as the rollback/delete on failure is already
happening inside the plugin's import method.

PVE/CLI/pvesm.pm

index ba2c91b6b5d76773b84e7e03e69dee849c8842d9..8af4e7fd46bcac53aedfc52ffe187547f1a2d249 100755 (executable)
@@ -258,6 +258,13 @@ __PACKAGE__->register_method ({
                optional => 1,
                default => 0,
            },
+           'delete-snapshot' => {
+               description => "A snapshot to delete on success",
+               type => 'string',
+               pattern => qr/[a-z0-9_\-]{1,80}/,
+               maxLength => 80,
+               optional => 1,
+           },
        },
     },
     returns => { type => 'null' },
@@ -275,8 +282,12 @@ __PACKAGE__->register_method ({
        }
 
        my $cfg = PVE::Storage::config();
-       PVE::Storage::volume_import($cfg, $infh, $param->{volume}, $param->{format},
+       my $volume = $param->{volume};
+       my $delete = $param->{'delete-snapshot'};
+       PVE::Storage::volume_import($cfg, $infh, $volume, $param->{format},
            $param->{base}, $param->{'with-snapshots'});
+       PVE::Storage::volume_snapshot_delete($cfg, $volume, $delete)
+           if defined($delete);
        return;
     }
 });