]> git.proxmox.com Git - pve-storage.git/commitdiff
Add cifsscan to API
authorWolfgang Link <w.link@proxmox.com>
Fri, 16 Mar 2018 09:22:57 +0000 (10:22 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Mar 2018 11:07:14 +0000 (12:07 +0100)
PVE/API2/Storage/Scan.pm

index 11d139ffc731afaee36ab329a6c25cac90629b7d..e9ce18e43ac53c575f374ca5b20e2b18fe3117a4 100644 (file)
@@ -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/