# GlusterFS storage support for Proxmox VE (API scan, pvesm CLI scan, @SHARED_STORAGE). # Tested against: libpve-storage-perl 9.1.5 --- a/usr/share/perl5/PVE/API2/Storage/Scan.pm +++ b/usr/share/perl5/PVE/API2/Storage/Scan.pm @@ -45,6 +45,7 @@ my $res = [ { method => 'cifs' }, + { method => 'glusterfs' }, { method => 'iscsi' }, { method => 'lvm' }, { method => 'nfs' }, @@ -246,6 +247,57 @@ }, }); +__PACKAGE__->register_method({ + name => 'glusterfsscan', + path => 'glusterfs', + method => 'GET', + description => "Scan remote GlusterFS server.", + protected => 1, + proxyto => "node", + permissions => { + check => ['perm', '/storage', ['Datastore.Allocate']], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + server => { + description => "The server address (name or IP).", + type => 'string', + format => 'pve-storage-server', + }, + }, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + volname => { + description => "The volume name.", + type => 'string', + }, + }, + }, + }, + code => sub { + my ($param) = @_; + + my $server = $param->{server}; + my $data = []; + PVE::Tools::run_command( + ['/usr/sbin/gluster', '--remote-host=' . $server, 'volume', 'list'], + outfunc => sub { + my $line = shift; + $line =~ s/^\s+|\s+$//g; + return if $line eq '' || $line eq 'No volumes present'; + push @$data, { volname => $line }; + }, + ); + return $data; + }, +}); + __PACKAGE__->register_method({ name => 'iscsiscan', path => 'iscsi', --- a/usr/share/perl5/PVE/CLI/pvesm.pm +++ b/usr/share/perl5/PVE/CLI/pvesm.pm @@ -691,6 +691,19 @@ } }, ], + glusterfs => [ + "PVE::API2::Storage::Scan", + 'glusterfsscan', + ['server'], + { node => $nodename }, + sub { + my $res = shift; + + foreach my $rec (@$res) { + printf "%s\n", $rec->{volname}; + } + }, + ], iscsi => [ "PVE::API2::Storage::Scan", 'iscsiscan', @@ -757,6 +770,7 @@ }, nfsscan => { alias => 'scan nfs' }, cifsscan => { alias => 'scan cifs' }, + glusterfsscan => { alias => 'scan glusterfs' }, iscsiscan => { alias => 'scan iscsi' }, lvmscan => { alias => 'scan lvm' }, lvmthinscan => { alias => 'scan lvmthin' }, --- a/usr/share/perl5/PVE/Storage/Plugin.pm +++ b/usr/share/perl5/PVE/Storage/Plugin.pm @@ -35,7 +35,7 @@ ); our @SHARED_STORAGE = ( - 'iscsi', 'nfs', 'cifs', 'rbd', 'cephfs', 'iscsidirect', 'zfs', 'drbd', 'pbs', + 'iscsi', 'nfs', 'cifs', 'rbd', 'cephfs', 'iscsidirect', 'glusterfs', 'zfs', 'drbd', 'pbs', ); our $QCOW2_PREALLOCATION = {