]>
git.proxmox.com Git - pve-storage.git/blob - PVE/API2/Storage/Scan.pm
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' },
57 __PACKAGE__-
>register_method({
61 description
=> "Scan remote NFS server.",
65 check
=> ['perm', '/storage', ['Datastore.Allocate']],
68 additionalProperties
=> 0,
70 node
=> get_standard_option
('pve-node'),
72 description
=> "The server address (name or IP).",
73 type
=> 'string', format
=> 'pve-storage-server',
83 description
=> "The exported path.",
87 description
=> "NFS export options.",
96 my $server = $param->{server
};
97 my $res = PVE
::Storage
::scan_nfs
($server);
100 foreach my $k (sort keys %$res) {
101 push @$data, { path
=> $k, options
=> $res->{$k} };
106 __PACKAGE__-
>register_method({
110 description
=> "Scan remote CIFS server.",
114 check
=> ['perm', '/storage', ['Datastore.Allocate']],
117 additionalProperties
=> 0,
119 node
=> get_standard_option
('pve-node'),
121 description
=> "The server address (name or IP).",
122 type
=> 'string', format
=> 'pve-storage-server',
125 description
=> "User name.",
130 description
=> "User password.",
135 description
=> "SMB domain (Workgroup).",
147 description
=> "The cifs share name.",
151 description
=> "Descriptive text from server.",
160 my $server = $param->{server
};
162 my $username = $param->{username
};
163 my $password = $param->{password
};
164 my $domain = $param->{domain
};
166 my $res = PVE
::Storage
::scan_cifs
($server, $username, $password, $domain);
169 foreach my $k (sort keys %$res) {
170 next if $k =~ m/NT_STATUS_/;
171 push @$data, { share
=> $k, description
=> $res->{$k} };
177 __PACKAGE__-
>register_method({
181 description
=> "Scan remote Proxmox Backup Server.",
185 check
=> ['perm', '/storage', ['Datastore.Allocate']],
188 additionalProperties
=> 0,
190 node
=> get_standard_option
('pve-node'),
192 description
=> "The server address (name or IP).",
193 type
=> 'string', format
=> 'pve-storage-server',
196 description
=> "User-name or API token-ID.",
200 description
=> "User password or API token secret.",
203 fingerprint
=> get_standard_option
('fingerprint-sha256', {
207 description
=> "Optional port.",
222 description
=> "The datastore name.",
226 description
=> "Comment from server.",
236 my $password = delete $param->{password
};
238 return PVE
::Storage
::PBSPlugin
::scan_datastores
($param, $password);
242 # Note: GlusterFS currently does not have an equivalent of showmount.
243 # As workaround, we simply use nfs showmount.
244 # see http://www.gluster.org/category/volumes/
245 __PACKAGE__-
>register_method({
246 name
=> 'glusterfsscan',
249 description
=> "Scan remote GlusterFS server.",
253 check
=> ['perm', '/storage', ['Datastore.Allocate']],
256 additionalProperties
=> 0,
258 node
=> get_standard_option
('pve-node'),
260 description
=> "The server address (name or IP).",
261 type
=> 'string', format
=> 'pve-storage-server',
271 description
=> "The volume name.",
280 my $server = $param->{server
};
281 my $res = PVE
::Storage
::scan_nfs
($server);
284 foreach my $path (sort keys %$res) {
285 if ($path =~ m!^/([^\s/]+)$!) {
286 push @$data, { volname
=> $1 };
292 __PACKAGE__-
>register_method({
296 description
=> "Scan remote iSCSI server.",
300 check
=> ['perm', '/storage', ['Datastore.Allocate']],
303 additionalProperties
=> 0,
305 node
=> get_standard_option
('pve-node'),
307 description
=> "The iSCSI portal (IP or DNS name with optional port).",
308 type
=> 'string', format
=> 'pve-storage-portal-dns',
318 description
=> "The iSCSI target name.",
322 description
=> "The iSCSI portal name.",
331 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
334 foreach my $k (sort keys %$res) {
335 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
341 __PACKAGE__-
>register_method({
345 description
=> "List local LVM volume groups.",
349 check
=> ['perm', '/storage', ['Datastore.Allocate']],
352 additionalProperties
=> 0,
354 node
=> get_standard_option
('pve-node'),
363 description
=> "The LVM logical volume group name.",
372 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
373 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
376 __PACKAGE__-
>register_method({
377 name
=> 'lvmthinscan',
380 description
=> "List local LVM Thin Pools.",
384 check
=> ['perm', '/storage', ['Datastore.Allocate']],
387 additionalProperties
=> 0,
389 node
=> get_standard_option
('pve-node'),
392 pattern
=> '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
403 description
=> "The LVM Thin Pool name (LVM logical volume).",
412 return PVE
::Storage
::LvmThinPlugin
::list_thinpools
($param->{vg
});
415 __PACKAGE__-
>register_method({
419 description
=> "Scan zfs pool list on local node.",
423 check
=> ['perm', '/storage', ['Datastore.Allocate']],
426 additionalProperties
=> 0,
428 node
=> get_standard_option
('pve-node'),
437 description
=> "ZFS pool name.",
446 return PVE
::Storage
::scan_zfs
();