]>
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'),
76 description
=> "ZFS pool name.",
85 return PVE
::Storage
::scan_zfs
();
88 __PACKAGE__-
>register_method ({
92 description
=> "Scan remote NFS server.",
96 check
=> ['perm', '/storage', ['Datastore.Allocate']],
99 additionalProperties
=> 0,
101 node
=> get_standard_option
('pve-node'),
102 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
111 description
=> "The exported path.",
115 description
=> "NFS export options.",
124 my $server = $param->{server
};
125 my $res = PVE
::Storage
::scan_nfs
($server);
128 foreach my $k (keys %$res) {
129 push @$data, { path
=> $k, options
=> $res->{$k} };
134 __PACKAGE__-
>register_method ({
138 description
=> "Scan remote CIFS server.",
142 check
=> ['perm', '/storage', ['Datastore.Allocate']],
145 additionalProperties
=> 0,
147 node
=> get_standard_option
('pve-node'),
148 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
149 username
=> { type
=> 'string', optional
=> 1 },
150 password
=> { type
=> 'string', optional
=> 1 },
151 domain
=> { type
=> 'string', optional
=> 1 },
160 description
=> "The cifs share name.",
164 description
=> "Descriptive text from server.",
173 my $server = $param->{server
};
175 my $username = $param->{username
};
176 my $password = $param->{password
};
177 my $domain = $param->{domain
};
179 my $res = PVE
::Storage
::scan_cifs
($server, $username, $password, $domain);
182 foreach my $k (keys %$res) {
183 next if $k =~ m/NT_STATUS_/;
184 push @$data, { share
=> $k, description
=> $res->{$k} };
190 # Note: GlusterFS currently does not have an equivalent of showmount.
191 # As workaround, we simply use nfs showmount.
192 # see http://www.gluster.org/category/volumes/
194 __PACKAGE__-
>register_method ({
195 name
=> 'glusterfsscan',
198 description
=> "Scan remote GlusterFS server.",
202 check
=> ['perm', '/storage', ['Datastore.Allocate']],
205 additionalProperties
=> 0,
207 node
=> get_standard_option
('pve-node'),
208 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
217 description
=> "The volume name.",
226 my $server = $param->{server
};
227 my $res = PVE
::Storage
::scan_nfs
($server);
230 foreach my $path (keys %$res) {
231 if ($path =~ m!^/([^\s/]+)$!) {
232 push @$data, { volname
=> $1 };
238 __PACKAGE__-
>register_method ({
242 description
=> "Scan remote iSCSI server.",
246 check
=> ['perm', '/storage', ['Datastore.Allocate']],
249 additionalProperties
=> 0,
251 node
=> get_standard_option
('pve-node'),
252 portal
=> { type
=> 'string', format
=> 'pve-storage-portal-dns' },
261 description
=> "The iSCSI target name.",
265 description
=> "The iSCSI portal name.",
274 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
277 foreach my $k (keys %$res) {
278 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
284 __PACKAGE__-
>register_method ({
288 description
=> "List local LVM volume groups.",
292 check
=> ['perm', '/storage', ['Datastore.Allocate']],
295 additionalProperties
=> 0,
297 node
=> get_standard_option
('pve-node'),
306 description
=> "The LVM logical volume group name.",
315 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
316 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
319 __PACKAGE__-
>register_method ({
320 name
=> 'lvmthinscan',
323 description
=> "List local LVM Thin Pools.",
327 check
=> ['perm', '/storage', ['Datastore.Allocate']],
330 additionalProperties
=> 0,
332 node
=> get_standard_option
('pve-node'),
335 pattern
=> '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
346 description
=> "The LVM Thin Pool name (LVM logical volume).",
355 return PVE
::Storage
::LvmThinPlugin
::list_thinpools
($param->{vg
});
358 __PACKAGE__-
>register_method ({
362 description
=> "List local USB devices.",
366 check
=> ['perm', '/', ['Sys.Modify']],
369 additionalProperties
=> 0,
371 node
=> get_standard_option
('pve-node'),
379 busnum
=> { type
=> 'integer'},
380 devnum
=> { type
=> 'integer'},
381 port
=> { type
=> 'integer'},
382 usbpath
=> { type
=> 'string', optional
=> 1},
383 level
=> { type
=> 'integer'},
384 class => { type
=> 'integer'},
385 vendid
=> { type
=> 'string'},
386 prodid
=> { type
=> 'string'},
387 speed
=> { type
=> 'string'},
389 product
=> { type
=> 'string', optional
=> 1 },
390 serial
=> { type
=> 'string', optional
=> 1 },
391 manufacturer
=> { type
=> 'string', optional
=> 1 },
398 return PVE
::Storage
::scan_usb
();