]>
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' },
52 __PACKAGE__-
>register_method ({
56 description
=> "Scan remote NFS server.",
60 check
=> ['perm', '/storage', ['Datastore.Allocate']],
63 additionalProperties
=> 0,
65 node
=> get_standard_option
('pve-node'),
66 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
74 path
=> { type
=> 'string'},
75 options
=> { type
=> 'string'},
82 my $server = $param->{server
};
83 my $res = PVE
::Storage
::scan_nfs
($server);
86 foreach my $k (keys %$res) {
87 push @$data, { path
=> $k, options
=> $res->{$k} };
92 # Note: GlusterFS currently does not have an equivalent of showmount.
93 # As workaround, we simply use nfs showmount.
94 # see http://www.gluster.org/category/volumes/
96 __PACKAGE__-
>register_method ({
97 name
=> 'glusterfsscan',
100 description
=> "Scan remote GlusterFS server.",
104 check
=> ['perm', '/storage', ['Datastore.Allocate']],
107 additionalProperties
=> 0,
109 node
=> get_standard_option
('pve-node'),
110 server
=> { type
=> 'string', format
=> 'pve-storage-server' },
118 volname
=> { type
=> 'string'},
125 my $server = $param->{server
};
126 my $res = PVE
::Storage
::scan_nfs
($server);
129 foreach my $path (keys %$res) {
130 if ($path =~ m!^/([^\s/]+)$!) {
131 push @$data, { volname
=> $1 };
137 __PACKAGE__-
>register_method ({
141 description
=> "Scan remote iSCSI server.",
145 check
=> ['perm', '/storage', ['Datastore.Allocate']],
148 additionalProperties
=> 0,
150 node
=> get_standard_option
('pve-node'),
151 portal
=> { type
=> 'string', format
=> 'pve-storage-portal-dns' },
159 target
=> { type
=> 'string'},
160 portal
=> { type
=> 'string'},
167 my $res = PVE
::Storage
::scan_iscsi
($param->{portal
});
170 foreach my $k (keys %$res) {
171 push @$data, { target
=> $k, portal
=> join(',', @{$res->{$k}}) };
177 __PACKAGE__-
>register_method ({
181 description
=> "List local LVM volume groups.",
185 check
=> ['perm', '/storage', ['Datastore.Allocate']],
188 additionalProperties
=> 0,
190 node
=> get_standard_option
('pve-node'),
198 vg
=> { type
=> 'string'},
205 my $res = PVE
::Storage
::LVMPlugin
::lvm_vgs
();
206 return PVE
::RESTHandler
::hash_to_array
($res, 'vg');
209 __PACKAGE__-
>register_method ({
213 description
=> "List local USB devices.",
217 check
=> ['perm', '/', ['Sys.Modify']],
220 additionalProperties
=> 0,
222 node
=> get_standard_option
('pve-node'),
230 busnum
=> { type
=> 'integer'},
231 devnum
=> { type
=> 'integer'},
232 port
=> { type
=> 'integer'},
233 usbpath
=> { type
=> 'string', optional
=> 1},
234 level
=> { type
=> 'integer'},
235 class => { type
=> 'integer'},
236 vendid
=> { type
=> 'string'},
237 prodid
=> { type
=> 'string'},
238 speed
=> { type
=> 'string'},
240 product
=> { type
=> 'string', optional
=> 1 },
241 serial
=> { type
=> 'string', optional
=> 1 },
242 manufacturer
=> { type
=> 'string', optional
=> 1 },
249 return PVE
::Storage
::scan_usb
();