use PVE::Storage::RBDPlugin;
use PVE::Storage::SheepdogPlugin;
use PVE::Storage::ISCSIDirectPlugin;
-use PVE::Storage::NexentaPlugin;
use PVE::Storage::GlusterfsPlugin;
+use PVE::Storage::ZFSPoolPlugin;
use PVE::Storage::ZFSPlugin;
# load and initialize all plugins
PVE::Storage::RBDPlugin->register();
PVE::Storage::SheepdogPlugin->register();
PVE::Storage::ISCSIDirectPlugin->register();
-PVE::Storage::NexentaPlugin->register();
PVE::Storage::GlusterfsPlugin->register();
+PVE::Storage::ZFSPoolPlugin->register();
PVE::Storage::ZFSPlugin->register();
PVE::Storage::Plugin->init();
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
return $plugin->volume_resize($scfg, $storeid, $volname, $size, $running);
} elsif ($volid =~ m|^(/.+)$| && -e $volid) {
- die "resize device is not possible";
+ die "resize file/device '$volid' is not possible\n";
} else {
- die "can't resize";
+ die "unable to parse volume ID '$volid'\n";
+ }
+}
+
+sub volume_rollback_is_possible {
+ my ($cfg, $volid, $snap) = @_;
+
+ 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_rollback_is_possible($scfg, $storeid, $volname, $snap);
+ } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
+ die "snapshot rollback file/device '$volid' is not possible\n";
+ } else {
+ die "unable to parse volume ID '$volid'\n";
}
}
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap, $running);
} elsif ($volid =~ m|^(/.+)$| && -e $volid) {
- die "snapshot device is not possible";
+ die "snapshot file/device '$volid' is not possible\n";
} else {
- die "can't snapshot";
+ die "unable to parse volume ID '$volid'\n";
}
}
if ($storeid) {
my $scfg = storage_config($cfg, $storeid);
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+ $plugin->volume_rollback_is_possible($scfg, $storeid, $volname, $snap);
return $plugin->volume_snapshot_rollback($scfg, $storeid, $volname, $snap);
} elsif ($volid =~ m|^(/.+)$| && -e $volid) {
- die "snapshot rollback device is not possible";
+ die "snapshot rollback file/device '$volid' is not possible\n";
} else {
- die "can't snapshot";
+ die "unable to parse volume ID '$volid'\n";
}
}
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
return $plugin->volume_snapshot_delete($scfg, $storeid, $volname, $snap, $running);
} elsif ($volid =~ m|^(/.+)$| && -e $volid) {
- die "snapshot delete device is not possible";
+ die "snapshot delete file/device '$volid' is not possible\n";
} else {
- die "can't delete snapshot";
+ die "unable to parse volume ID '$volid'\n";
}
}
}
sub vdisk_clone {
- my ($cfg, $volid, $vmid) = @_;
+ my ($cfg, $volid, $vmid, $snap) = @_;
my ($storeid, $volname) = parse_volume_id($volid);
# lock shared storage
return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
- my $volname = $plugin->clone_image($scfg, $storeid, $volname, $vmid);
+ my $volname = $plugin->clone_image($scfg, $storeid, $volname, $vmid, $snap);
return "$storeid:$volname";
});
}
}
}
}
- my $cleanup_worker = $plugin->free_image($storeid, $scfg, $volname, $isBase);
+ $cleanup_worker = $plugin->free_image($storeid, $scfg, $volname, $isBase);
});
return if !$cleanup_worker;
return $res;
}
+sub scan_zfs {
+
+ my $cmd = ['zpool', 'list', '-H', '-o', 'name,size,free'];
+
+ my $res = [];
+ run_command($cmd, outfunc => sub {
+ my $line = shift;
+
+ if ($line =~m/^(\S+)\s+(\S+)\s+(\S+)$/) {
+ my ($pool, $size_str, $free_str) = ($1, $2, $3);
+ my $size = PVE::Storage::ZFSPoolPlugin::zfs_parse_size($size_str);
+ my $free = PVE::Storage::ZFSPoolPlugin::zfs_parse_size($free_str);
+ push @$res, { pool => $pool, size => $size, free => $free };
+ }
+ });
+
+ return $res;
+}
+
sub resolv_portal {
my ($portal, $noerr) = @_;