This function we need for replica to handle snapshots on remote nodes. --- PVE/Storage.pm | 15 +++++++++++++++ PVE/Storage/Plugin.pm | 7 +++++++ PVE/Storage/ZFSPoolPlugin.pm | 13 ++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 8fe9f4b..68c39ca 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -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) = @_; diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 641ab04..6bf5baa 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -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) = @_; diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index 2cf1bc7..7579472 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -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 { @@ -518,12 +521,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"); } -- 2.1.4 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel