From b9cfb8cac797193676aa0d46131438510f2108bc Mon Sep 17 00:00:00 2001 From: Wolfgang Link Date: Fri, 16 Mar 2018 10:22:57 +0100 Subject: [PATCH] Add cifsscan to API --- PVE/API2/Storage/Scan.pm | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/PVE/API2/Storage/Scan.pm b/PVE/API2/Storage/Scan.pm index 11d139f..e9ce18e 100644 --- a/PVE/API2/Storage/Scan.pm +++ b/PVE/API2/Storage/Scan.pm @@ -45,6 +45,7 @@ __PACKAGE__->register_method ({ { method => 'glusterfs' }, { method => 'usb' }, { method => 'zfs' }, + { method => 'cifs' }, ]; return $res; @@ -121,6 +122,56 @@ __PACKAGE__->register_method ({ return $data; }}); +__PACKAGE__->register_method ({ + name => 'cifsscan', + path => 'cifs', + method => 'GET', + description => "Scan remote CIFS 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' }, + username => { type => 'string', optional => 1 }, + password => { type => 'string', optional => 1 }, + domain => { type => 'string', optional => 1 }, + }, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + share => { type => 'string'}, + description => { type => 'string'}, + }, + }, + }, + code => sub { + my ($param) = @_; + + my $server = $param->{server}; + + my $username = $param->{username}; + my $password = $param->{password}; + my $domain = $param->{domain}; + + my $res = PVE::Storage::scan_cifs($server, $username, $password, $domain); + + my $data = []; + foreach my $k (keys %$res) { + next if $k =~ m/NT_STATUS_/; + push @$data, { share => $k, description => $res->{$k} }; + } + + 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/ -- 2.39.5