]>
git.proxmox.com Git - pve-storage.git/blob - PVE/API2/Storage/Scan.pm
0e6fd9a3117df12f56b6828040cf96e5db01e37c
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
=> "Scan remote NFS server.",
25 check
=> ['perm', '/storage', ['Datastore.Allocate']],
28 additionalProperties
=> 0,
30 node
=> get_standard_option
('pve-node'),
32 description
=> "The server address (name or IP).",
33 type
=> 'string', format
=> 'pve-storage-server',
43 description
=> "The exported path.",
47 description
=> "NFS export options.",
56 my $server = $param->{server
};
57 my $res = PVE
::Storage
::scan_nfs
($server);
60 foreach my $k (sort keys %$res) {
61 push @$data, { path
=> $k, options
=> $res->{$k} };
66 __PACKAGE__-
>register_method({
70 description
=> "Scan remote CIFS server.",
74 check
=> ['perm', '/storage', ['Datastore.Allocate']],
77 additionalProperties
=> 0,
79 node
=> get_standard_option
('pve-node'),
81 description
=> "The server address (name or IP).",
82 type
=> 'string', format
=> 'pve-storage-server',
85 description
=> "User name.",
90 description
=> "User password.",
95 description
=> "SMB domain (Workgroup).",
107 description
=> "The cifs share name.",
111 description
=> "Descriptive text from server.",
120 my $server = $param->{server
};
122 my $username = $param->{username
};
123 my $password = $param->{password
};
124 my $domain = $param->{domain
};
126 my $res = PVE
::Storage
::scan_cifs
($server, $username, $password, $domain);
129 foreach my $k (sort keys %$res) {
130 push @$data, { share
=> $k, description
=> $res->{$k} };
136 # Note: GlusterFS currently does not have an equivalent of showmount.
137 # As workaround, we simply use nfs showmount.
138 # see http://www.gluster.org/category/volumes/
139 __PACKAGE__-
>register_method({
140 name
=> 'glusterfsscan',
143 description
=> "Scan remote GlusterFS server.",
147 check
=> ['perm', '/storage', ['Datastore.Allocate']],
150 additionalProperties
=> 0,
152 node
=> get_standard_option
('pve-node'),
154 description
=> "The server address (name or IP).",
155 type
=> 'string', format
=> 'pve-storage-server',
165 description
=> "The volume name.",
174 my $server = $param->{server
};
175 my $res = PVE
::Storage
::scan_nfs
($server);
178 foreach my $path (sort keys %$res) {
179 if ($path =~ m!^/([^\s/]+)$!) {
180 push @$data, { volname
=> $1 };
186 __PACKAGE__-
>register_method({
190 description
=> "Scan remote iSCSI server.",
194 check
=> ['perm', '/storage', ['Datastore.Allocate']],
197 additionalProperties
=> 0,
199 node
=> get_standard_option
('pve-node'),
201 description
=> "The iSCSI portal (IP or DNS name with optional port).",
202 type
=> 'string', format
=> 'pve-storage-portal-dns',
212 description
=> "The iSCSI target name.",
216 description
=> "The iSCSI portal name.",
225 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
228 foreach my $k (sort keys %$res) {
229 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
235 __PACKAGE__-
>register_method({
239 description
=> "List local LVM volume groups.",
243 check
=> ['perm', '/storage', ['Datastore.Allocate']],
246 additionalProperties
=> 0,
248 node
=> get_standard_option
('pve-node'),
257 description
=> "The LVM logical volume group name.",
266 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
267 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
270 __PACKAGE__-
>register_method({
271 name
=> 'lvmthinscan',
274 description
=> "List local LVM Thin Pools.",
278 check
=> ['perm', '/storage', ['Datastore.Allocate']],
281 additionalProperties
=> 0,
283 node
=> get_standard_option
('pve-node'),
286 pattern
=> '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
297 description
=> "The LVM Thin Pool name (LVM logical volume).",
306 return PVE
::Storage
::LvmThinPlugin
::list_thinpools
($param->{vg
});
309 __PACKAGE__-
>register_method({
313 description
=> "Scan zfs pool list on local node.",
317 check
=> ['perm', '/storage', ['Datastore.Allocate']],
320 additionalProperties
=> 0,
322 node
=> get_standard_option
('pve-node'),
331 description
=> "ZFS pool name.",
340 return PVE
::Storage
::scan_zfs
();