]>
git.proxmox.com Git - pve-storage.git/blob - PVE/API2/Storage/Scan.pm
15b39b50eb76a284797a73750fd7adf343dd8514
1 package PVE
::API2
::Storage
::Scan
;
6 # NOTE: This API endpoints are mounted by pve-manager's API2::Node module and pvesm CLI
8 use PVE
::JSONSchema
qw(get_standard_option);
11 use PVE
::Storage
::LVMPlugin
;
15 use base
qw(PVE::RESTHandler);
17 __PACKAGE__-
>register_method({
21 description
=> "Index of available scan methods",
26 additionalProperties
=> 0,
28 node
=> get_standard_option
('pve-node'),
36 method => { type
=> 'string'},
39 links
=> [ { rel
=> 'child', href
=> "{method}" } ],
46 { method => 'glusterfs' },
47 { method => 'iscsi' },
51 # FIXME: remove with 7.0 (replaced by /nodes/<node>/hardware/usb)
59 __PACKAGE__-
>register_method({
63 description
=> "Scan remote NFS server.",
67 check
=> ['perm', '/storage', ['Datastore.Allocate']],
70 additionalProperties
=> 0,
72 node
=> get_standard_option
('pve-node'),
74 description
=> "The server address (name or IP).",
75 type
=> 'string', format
=> 'pve-storage-server',
85 description
=> "The exported path.",
89 description
=> "NFS export options.",
98 my $server = $param->{server
};
99 my $res = PVE
::Storage
::scan_nfs
($server);
102 foreach my $k (sort keys %$res) {
103 push @$data, { path
=> $k, options
=> $res->{$k} };
108 __PACKAGE__-
>register_method({
112 description
=> "Scan remote CIFS server.",
116 check
=> ['perm', '/storage', ['Datastore.Allocate']],
119 additionalProperties
=> 0,
121 node
=> get_standard_option
('pve-node'),
123 description
=> "The server address (name or IP).",
124 type
=> 'string', format
=> 'pve-storage-server',
127 description
=> "User name.",
132 description
=> "User password.",
137 description
=> "SMB domain (Workgroup).",
149 description
=> "The cifs share name.",
153 description
=> "Descriptive text from server.",
162 my $server = $param->{server
};
164 my $username = $param->{username
};
165 my $password = $param->{password
};
166 my $domain = $param->{domain
};
168 my $res = PVE
::Storage
::scan_cifs
($server, $username, $password, $domain);
171 foreach my $k (sort keys %$res) {
172 next if $k =~ m/NT_STATUS_/;
173 push @$data, { share
=> $k, description
=> $res->{$k} };
179 __PACKAGE__-
>register_method({
183 description
=> "Scan remote Proxmox Backup Server.",
187 check
=> ['perm', '/storage', ['Datastore.Allocate']],
190 additionalProperties
=> 0,
192 node
=> get_standard_option
('pve-node'),
194 description
=> "The server address (name or IP).",
195 type
=> 'string', format
=> 'pve-storage-server',
198 description
=> "User-name or API token-ID.",
202 description
=> "User password or API token secret.",
205 fingerprint
=> get_standard_option
('fingerprint-sha256', {
209 description
=> "Optional port.",
224 description
=> "The datastore name.",
228 description
=> "Comment from server.",
238 my $password = delete $param->{password
};
240 return PVE
::Storage
::PBSPlugin
::scan_datastores
($param, $password);
244 # Note: GlusterFS currently does not have an equivalent of showmount.
245 # As workaround, we simply use nfs showmount.
246 # see http://www.gluster.org/category/volumes/
247 __PACKAGE__-
>register_method({
248 name
=> 'glusterfsscan',
251 description
=> "Scan remote GlusterFS server.",
255 check
=> ['perm', '/storage', ['Datastore.Allocate']],
258 additionalProperties
=> 0,
260 node
=> get_standard_option
('pve-node'),
262 description
=> "The server address (name or IP).",
263 type
=> 'string', format
=> 'pve-storage-server',
273 description
=> "The volume name.",
282 my $server = $param->{server
};
283 my $res = PVE
::Storage
::scan_nfs
($server);
286 foreach my $path (sort keys %$res) {
287 if ($path =~ m!^/([^\s/]+)$!) {
288 push @$data, { volname
=> $1 };
294 __PACKAGE__-
>register_method({
298 description
=> "Scan remote iSCSI server.",
302 check
=> ['perm', '/storage', ['Datastore.Allocate']],
305 additionalProperties
=> 0,
307 node
=> get_standard_option
('pve-node'),
309 description
=> "The iSCSI portal (IP or DNS name with optional port).",
310 type
=> 'string', format
=> 'pve-storage-portal-dns',
320 description
=> "The iSCSI target name.",
324 description
=> "The iSCSI portal name.",
333 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
336 foreach my $k (sort keys %$res) {
337 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
343 __PACKAGE__-
>register_method({
347 description
=> "List local LVM volume groups.",
351 check
=> ['perm', '/storage', ['Datastore.Allocate']],
354 additionalProperties
=> 0,
356 node
=> get_standard_option
('pve-node'),
365 description
=> "The LVM logical volume group name.",
374 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
375 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
378 __PACKAGE__-
>register_method({
379 name
=> 'lvmthinscan',
382 description
=> "List local LVM Thin Pools.",
386 check
=> ['perm', '/storage', ['Datastore.Allocate']],
389 additionalProperties
=> 0,
391 node
=> get_standard_option
('pve-node'),
394 pattern
=> '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
405 description
=> "The LVM Thin Pool name (LVM logical volume).",
414 return PVE
::Storage
::LvmThinPlugin
::list_thinpools
($param->{vg
});
417 __PACKAGE__-
>register_method({
421 description
=> "Scan zfs pool list on local node.",
425 check
=> ['perm', '/storage', ['Datastore.Allocate']],
428 additionalProperties
=> 0,
430 node
=> get_standard_option
('pve-node'),
439 description
=> "ZFS pool name.",
448 return PVE
::Storage
::scan_zfs
();
451 # FIXME: remove with 7.0 (replaced by /nodes/<node>/hardware/usb)
452 __PACKAGE__-
>register_method({
456 description
=> "List local USB devices.",
460 check
=> ['perm', '/', ['Sys.Modify']],
463 additionalProperties
=> 0,
465 node
=> get_standard_option
('pve-node'),
473 busnum
=> { type
=> 'integer'},
474 class => { type
=> 'integer'},
475 devnum
=> { type
=> 'integer'},
476 level
=> { type
=> 'integer'},
477 manufacturer
=> { type
=> 'string', optional
=> 1 },
478 port
=> { type
=> 'integer'},
479 prodid
=> { type
=> 'string'},
480 product
=> { type
=> 'string', optional
=> 1 },
481 serial
=> { type
=> 'string', optional
=> 1 },
482 speed
=> { type
=> 'string'},
483 usbpath
=> { type
=> 'string', optional
=> 1},
484 vendid
=> { type
=> 'string'},
491 return PVE
::SysFSTools
::scan_usb
();