]> git.proxmox.com Git - pve-storage.git/commitdiff
Add function volume_snapshot_delete_remote.
authorWolfgang Link <w.link@proxmox.com>
Mon, 24 Apr 2017 15:15:29 +0000 (17:15 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 28 Apr 2017 08:05:27 +0000 (10:05 +0200)
This function we need for replica to handle snapshots on remote nodes.

PVE/Storage.pm
PVE/Storage/Plugin.pm
PVE/Storage/ZFSPoolPlugin.pm

index 8fe9f4b013a873a8101deaec27ce7380b8b1cf93..68c39ca01ea6ef50eeeaebbb5ac00811f6f89d07 100755 (executable)
@@ -250,6 +250,21 @@ sub volume_snapshot_rollback {
     }
 }
 
+sub volume_snapshot_delete_remote {
+    my ($cfg, $volid, $snap, $ip) = @_;
+
+    my ($storeid, $volname) = parse_volume_id($volid, 1);
+    if ($storeid) {
+        my $scfg = storage_config($cfg, $storeid);
+        my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+        return $plugin->volume_snapshot_delete_remote($scfg, $storeid, $volname, $snap, $ip);
+    } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+        die "snapshot delete file/device '$volid' is not possible\n";
+    } else {
+       die "unable to parse volume ID '$volid'\n";
+    }
+}
+
 sub volume_snapshot_delete {
     my ($cfg, $volid, $snap, $running) = @_;
 
index 641ab045a8b85581f6e8b8b72b93f8d4b2c24027..6bf5baa841af98eea73fc9ca472406c6d531312c 100644 (file)
@@ -725,6 +725,13 @@ sub volume_snapshot_rollback {
     return undef;
 }
 
+sub volume_snapshot_delete_remote {
+    my ($class, $scfg, $storeid, $volname, $snap, $ip) = @_;
+
+    # implement in subclass
+    die "Volume_snapshot_delete_remote is not implemented for $class";
+}
+
 sub volume_snapshot_delete {
     my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
 
index 82a62d3af27479295db459f865434a70fb2d09d3..b023ce77731094d2028ca53327f5efbfa7e33d62 100644 (file)
@@ -180,7 +180,10 @@ sub zfs_request {
     }
 
     push @$cmd, @params;
+    if ($ip) {
+       $ip = "[$ip]" if Net::IP::ip_is_ipv6($ip);
+       unshift @$cmd, 'ssh', '-o', 'BatchMode=yes', "root\@${ip}", '--';
+    }
     my $msg = '';
 
     my $output = sub {
@@ -517,12 +520,20 @@ sub volume_send {
     }
 }
 
+sub volume_snapshot_delete_remote {
+    my ($class, $scfg, $storeid, $volname, $snap, $ip) = @_;
+
+    my $vname = ($class->parse_volname($volname))[1];
+    $class->zfs_request($scfg, $ip, undef, 'destroy', "$scfg->{pool}/$vname\@$snap");
+}
+
 sub volume_snapshot_delete {
     my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
 
     my $vname = ($class->parse_volname($volname))[1];
 
     $class->deactivate_volume($storeid, $scfg, $vname, $snap, {});
+
     $class->zfs_request($scfg, undef, undef, 'destroy', "$scfg->{pool}/$vname\@$snap");
 }