API: add scan method for glusterfs

This commit is contained in:
Dietmar Maurer
2013-08-13 10:06:03 +02:00
parent f78bb9c87d
commit 3cf5e19edc
3 changed files with 56 additions and 0 deletions

View File

@ -42,6 +42,7 @@ __PACKAGE__->register_method ({
{ method => 'lvm' },
{ method => 'iscsi' },
{ method => 'nfs' },
{ method => 'glusterfs' },
{ method => 'usb' },
];
@ -88,6 +89,51 @@ __PACKAGE__->register_method ({
return $data;
}});
# Note: GlusterFS currently does not have an equivalent of showmount.
# As workaround, we simply use nfs showmount.
# see http://www.gluster.org/category/volumes/
__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 => { type => 'string', format => 'pve-storage-server' },
},
},
returns => {
type => 'array',
items => {
type => "object",
properties => {
volname => { type => 'string'},
},
},
},
code => sub {
my ($param) = @_;
my $server = $param->{server};
my $res = PVE::Storage::scan_nfs($server);
my $data = [];
foreach my $path (keys %$res) {
if ($path =~ m!^/([^\s/]+)$!) {
push @$data, { volname => $1 };
}
}
return $data;
}});
__PACKAGE__->register_method ({
name => 'iscsiscan',
path => 'iscsi',