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 <[email protected]> --- 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 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
