[pve-devel] [RFC pve-storage master v1 08/12] plugin: zfspool: add 'short-name' and form view for ZFS pool plugin
Max R. Carrara
m.carrara at proxmox.com
Mon Sep 8 20:00:52 CEST 2025
This commit demonstrates how the 'short-name' key and the
`get_form_view()` method can be added to a plugin.
Signed-off-by: Max R. Carrara <m.carrara at proxmox.com>
---
src/PVE/Storage/ZFSPoolPlugin.pm | 67 ++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPoolPlugin.pm
index d8d8d0f..6de5ee1 100644
--- a/src/PVE/Storage/ZFSPoolPlugin.pm
+++ b/src/PVE/Storage/ZFSPoolPlugin.pm
@@ -20,9 +20,13 @@ sub type {
sub plugindata {
return {
+ 'short-name' => 'ZFS',
content => [{ images => 1, rootdir => 1 }, { images => 1, rootdir => 1 }],
format => [{ raw => 1, subvol => 1 }, 'raw'],
'sensitive-properties' => {},
+ views => {
+ form => 1,
+ },
};
}
@@ -140,6 +144,69 @@ sub on_add_hook {
return;
}
+sub get_form_view {
+ my ($class, $context) = @_;
+
+ my $pool_selection_values = [];
+
+ my $cmd = ['zfs', 'list', '-t', 'filesystem', '-Hp', '-o', 'name'];
+ run_command(
+ $cmd,
+ outfunc => sub {
+ my ($line) = @_;
+
+ if ($line =~ m/ ^ (?<pool>\S+) \s* $/xn) {
+ my $pool = $+{pool};
+ push($pool_selection_values->@*, [$pool, $pool]);
+ }
+ },
+ );
+
+ $pool_selection_values = [ sort { $a->[0] cmp $b->[0] } $pool_selection_values->@* ];
+
+ my $view = {
+ version => 1,
+ definition => {
+ general => {
+ columns => [
+ {
+ fields => [
+ {
+ property => 'pool',
+ label => "Pool",
+ 'field-type' => 'selection',
+ attributes => {
+ 'selection-values' => $pool_selection_values,
+ required => 1,
+ readonly => $context->{mode} eq 'update',
+ },
+ },
+ ],
+ },
+ {
+ fields => [
+ {
+ property => 'sparse',
+ label => "Thin provision",
+ 'field-type' => 'boolean',
+ attributes => {},
+ },
+ {
+ property => 'blocksize',
+ label => "Block Size",
+ 'field-type' => 'string',
+ attributes => {},
+ },
+ ],
+ },
+ ],
+ },
+ },
+ };
+
+ return $view;
+}
+
sub path {
my ($class, $scfg, $volname, $storeid, $snapname) = @_;
--
2.47.2
More information about the pve-devel
mailing list