From 7118dd916bb8bdfdc1445e3aa3b2e760476a1239 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 27 Jun 2017 06:17:58 +0200 Subject: [PATCH] PVE::Storage::storage_can_replicate - hew helper --- PVE/Storage.pm | 11 +++++++++++ PVE/Storage/Plugin.pm | 6 ++++++ PVE/Storage/ZFSPlugin.pm | 6 ++++++ PVE/Storage/ZFSPoolPlugin.pm | 8 ++++++++ 4 files changed, 31 insertions(+) diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 4772c6c..cf1e5ec 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -145,6 +145,17 @@ sub storage_check_enabled { return storage_check_node($cfg, $storeid, $node, $noerr); } +# storage_can_replicate: +# return true if storage supports replication +# (volumes alocated with vdisk_alloc() has replication feature) +sub storage_can_replicate { + my ($cfg, $storeid, $format) = @_; + + my $scfg = storage_config($cfg, $storeid); + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + return $plugin->storage_can_replicate($scfg, $storeid, $format); +} + sub storage_ids { my ($cfg) = @_; diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 50a99c4..b640712 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -742,6 +742,12 @@ sub volume_snapshot_delete { return undef; } +sub storage_can_replicate { + my ($class, $scfg, $storeid, $format) = @_; + + return 0; +} + sub volume_has_feature { my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_; diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm index 8658f0e..d4cbb8d 100644 --- a/PVE/Storage/ZFSPlugin.pm +++ b/PVE/Storage/ZFSPlugin.pm @@ -336,6 +336,12 @@ sub volume_snapshot_rollback { $class->zfs_add_lun_mapping_entry($scfg, $volname); } +sub storage_can_replicate { + my ($class, $scfg, $storeid, $format) = @_; + + return 0; +} + sub volume_has_feature { my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_; diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm index fbda2c4..b971e3a 100644 --- a/PVE/Storage/ZFSPoolPlugin.pm +++ b/PVE/Storage/ZFSPoolPlugin.pm @@ -623,6 +623,14 @@ sub volume_resize { return $new_size; } +sub storage_can_replicate { + my ($class, $scfg, $storeid, $format) = @_; + + return 1 if $format eq 'raw' || $format eq 'subvol'; + + return 0; +} + sub volume_has_feature { my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;