]>
git.proxmox.com Git - pve-storage.git/blob - PVE/API2/Storage/Scan.pm
1 package PVE
::API2
::Storage
::Scan
;
8 use PVE
::Storage
::LVMPlugin
;
9 use HTTP
::Status
qw(:constants);
10 use PVE
::JSONSchema
qw(get_standard_option);
14 use base
qw(PVE::RESTHandler);
16 __PACKAGE__-
>register_method ({
20 description
=> "Index of available scan methods",
25 additionalProperties
=> 0,
27 node
=> get_standard_option
('pve-node'),
34 properties
=> { method => { type
=> 'string'} },
36 links
=> [ { rel
=> 'child', href
=> "{method}" } ],
43 { method => 'iscsi' },
45 { method => 'glusterfs' },
54 __PACKAGE__-
>register_method ({
58 description
=> "Scan zfs pool list on local node.",
62 check
=> ['perm', '/storage', ['Datastore.Allocate']],
65 additionalProperties
=> 0,
67 node
=> get_standard_option
('pve-node'),
75 pool
=> { type
=> 'string'},
82 return PVE
::Storage
::scan_zfs
();
85 __PACKAGE__-
>register_method ({
89 description
=> "Scan remote NFS server.",
93 check
=> ['perm', '/storage', ['Datastore.Allocate']],
96 additionalProperties
=> 0,
98 node
=> get_standard_option
('pve-node'),
99 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
107 path
=> { type
=> 'string'},
108 options
=> { type
=> 'string'},
115 my $server = $param->{server
};
116 my $res = PVE
::Storage
::scan_nfs
($server);
119 foreach my $k (keys %$res) {
120 push @$data, { path
=> $k, options
=> $res->{$k} };
125 __PACKAGE__-
>register_method ({
129 description
=> "Scan remote CIFS server.",
133 check
=> ['perm', '/storage', ['Datastore.Allocate']],
136 additionalProperties
=> 0,
138 node
=> get_standard_option
('pve-node'),
139 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
140 username
=> { type
=> 'string', optional
=> 1 },
141 password
=> { type
=> 'string', optional
=> 1 },
142 domain
=> { type
=> 'string', optional
=> 1 },
150 share
=> { type
=> 'string'},
151 description
=> { type
=> 'string'},
158 my $server = $param->{server
};
160 my $username = $param->{username
};
161 my $password = $param->{password
};
162 my $domain = $param->{domain
};
164 my $res = PVE
::Storage
::scan_cifs
($server, $username, $password, $domain);
167 foreach my $k (keys %$res) {
168 next if $k =~ m/NT_STATUS_/;
169 push @$data, { share
=> $k, description
=> $res->{$k} };
175 # Note: GlusterFS currently does not have an equivalent of showmount.
176 # As workaround, we simply use nfs showmount.
177 # see http://www.gluster.org/category/volumes/
179 __PACKAGE__-
>register_method ({
180 name
=> 'glusterfsscan',
183 description
=> "Scan remote GlusterFS server.",
187 check
=> ['perm', '/storage', ['Datastore.Allocate']],
190 additionalProperties
=> 0,
192 node
=> get_standard_option
('pve-node'),
193 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
201 volname
=> { type
=> 'string'},
208 my $server = $param->{server
};
209 my $res = PVE
::Storage
::scan_nfs
($server);
212 foreach my $path (keys %$res) {
213 if ($path =~ m!^/([^\s/]+)$!) {
214 push @$data, { volname
=> $1 };
220 __PACKAGE__-
>register_method ({
224 description
=> "Scan remote iSCSI server.",
228 check
=> ['perm', '/storage', ['Datastore.Allocate']],
231 additionalProperties
=> 0,
233 node
=> get_standard_option
('pve-node'),
234 portal
=> { type
=> 'string', format
=> 'pve-storage-portal-dns' },
242 target
=> { type
=> 'string'},
243 portal
=> { type
=> 'string'},
250 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
253 foreach my $k (keys %$res) {
254 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
260 __PACKAGE__-
>register_method ({
264 description
=> "List local LVM volume groups.",
268 check
=> ['perm', '/storage', ['Datastore.Allocate']],
271 additionalProperties
=> 0,
273 node
=> get_standard_option
('pve-node'),
281 vg
=> { type
=> 'string'},
288 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
289 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
292 __PACKAGE__-
>register_method ({
293 name
=> 'lvmthinscan',
296 description
=> "List local LVM Thin Pools.",
300 check
=> ['perm', '/storage', ['Datastore.Allocate']],
303 additionalProperties
=> 0,
305 node
=> get_standard_option
('pve-node'),
308 pattern
=> '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
318 lv
=> { type
=> 'string'},
325 return PVE
::Storage
::LvmThinPlugin
::list_thinpools
($param->{vg
});
328 __PACKAGE__-
>register_method ({
332 description
=> "List local USB devices.",
336 check
=> ['perm', '/', ['Sys.Modify']],
339 additionalProperties
=> 0,
341 node
=> get_standard_option
('pve-node'),
349 busnum
=> { type
=> 'integer'},
350 devnum
=> { type
=> 'integer'},
351 port
=> { type
=> 'integer'},
352 usbpath
=> { type
=> 'string', optional
=> 1},
353 level
=> { type
=> 'integer'},
354 class => { type
=> 'integer'},
355 vendid
=> { type
=> 'string'},
356 prodid
=> { type
=> 'string'},
357 speed
=> { type
=> 'string'},
359 product
=> { type
=> 'string', optional
=> 1 },
360 serial
=> { type
=> 'string', optional
=> 1 },
361 manufacturer
=> { type
=> 'string', optional
=> 1 },
368 return PVE
::Storage
::scan_usb
();