]>
git.proxmox.com Git - pve-storage.git/blob - PVE/API2/Storage/Scan.pm
3e3f2c3d3b1076d5c6e24d1d380262b9db5d52ff
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' },
53 __PACKAGE__-
>register_method ({
57 description
=> "Scan zfs pool list on local node.",
61 check
=> ['perm', '/storage', ['Datastore.Allocate']],
64 additionalProperties
=> 0,
66 node
=> get_standard_option
('pve-node'),
74 pool
=> { type
=> 'string'},
81 return PVE
::Storage
::scan_zfs
();
84 __PACKAGE__-
>register_method ({
88 description
=> "Scan remote NFS server.",
92 check
=> ['perm', '/storage', ['Datastore.Allocate']],
95 additionalProperties
=> 0,
97 node
=> get_standard_option
('pve-node'),
98 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
106 path
=> { type
=> 'string'},
107 options
=> { type
=> 'string'},
114 my $server = $param->{server
};
115 my $res = PVE
::Storage
::scan_nfs
($server);
118 foreach my $k (keys %$res) {
119 push @$data, { path
=> $k, options
=> $res->{$k} };
124 # Note: GlusterFS currently does not have an equivalent of showmount.
125 # As workaround, we simply use nfs showmount.
126 # see http://www.gluster.org/category/volumes/
128 __PACKAGE__-
>register_method ({
129 name
=> 'glusterfsscan',
132 description
=> "Scan remote GlusterFS server.",
136 check
=> ['perm', '/storage', ['Datastore.Allocate']],
139 additionalProperties
=> 0,
141 node
=> get_standard_option
('pve-node'),
142 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
150 volname
=> { type
=> 'string'},
157 my $server = $param->{server
};
158 my $res = PVE
::Storage
::scan_nfs
($server);
161 foreach my $path (keys %$res) {
162 if ($path =~ m!^/([^\s/]+)$!) {
163 push @$data, { volname
=> $1 };
169 __PACKAGE__-
>register_method ({
173 description
=> "Scan remote iSCSI server.",
177 check
=> ['perm', '/storage', ['Datastore.Allocate']],
180 additionalProperties
=> 0,
182 node
=> get_standard_option
('pve-node'),
183 portal
=> { type
=> 'string', format
=> 'pve-storage-portal-dns' },
191 target
=> { type
=> 'string'},
192 portal
=> { type
=> 'string'},
199 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
202 foreach my $k (keys %$res) {
203 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
209 __PACKAGE__-
>register_method ({
213 description
=> "List local LVM volume groups.",
217 check
=> ['perm', '/storage', ['Datastore.Allocate']],
220 additionalProperties
=> 0,
222 node
=> get_standard_option
('pve-node'),
230 vg
=> { type
=> 'string'},
237 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
238 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
241 __PACKAGE__-
>register_method ({
242 name
=> 'thinlvmscan',
245 description
=> "List local LVM Thin Pools.",
249 check
=> ['perm', '/storage', ['Datastore.Allocate']],
252 additionalProperties
=> 0,
254 node
=> get_standard_option
('pve-node'),
257 pattern
=> '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage
267 lv
=> { type
=> 'string'},
273 return PVE
::Storage
::LvmThinPlugin
::list_thinpools
($param->{vg
});
276 __PACKAGE__-
>register_method ({
280 description
=> "List local USB devices.",
284 check
=> ['perm', '/', ['Sys.Modify']],
287 additionalProperties
=> 0,
289 node
=> get_standard_option
('pve-node'),
297 busnum
=> { type
=> 'integer'},
298 devnum
=> { type
=> 'integer'},
299 port
=> { type
=> 'integer'},
300 usbpath
=> { type
=> 'string', optional
=> 1},
301 level
=> { type
=> 'integer'},
302 class => { type
=> 'integer'},
303 vendid
=> { type
=> 'string'},
304 prodid
=> { type
=> 'string'},
305 speed
=> { type
=> 'string'},
307 product
=> { type
=> 'string', optional
=> 1 },
308 serial
=> { type
=> 'string', optional
=> 1 },
309 manufacturer
=> { type
=> 'string', optional
=> 1 },
316 return PVE
::Storage
::scan_usb
();