Diskmanage: also include partitions with get_disks if flag is set

and have a parent key for partitions, to be able to see the associated disk in
the result without having to rely on naming heuristics (just adding a number at
the end doesn't work for NVMes).

The disk's usage will not be based on the partitions usage if the flag is set,
but will simply be 'partitions'.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner
2021-01-26 12:45:27 +01:00
committed by Thomas Lamprecht
parent 6a1919b137
commit 2949c537d9
2 changed files with 31 additions and 5 deletions

View File

@ -88,6 +88,12 @@ __PACKAGE__->register_method ({
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
'include-partitions' => {
description => "Also include partitions.",
type => 'boolean',
optional => 1,
default => 0,
},
skipsmart => {
description => "Skip smart checks.",
type => 'boolean',
@ -120,6 +126,12 @@ __PACKAGE__->register_method ({
serial => { type => 'string', optional => 1 },
wwn => { type => 'string', optional => 1},
health => { type => 'string', optional => 1},
parent => {
type => 'string',
description => 'For partitions only. The device path of ' .
'the disk the partition resides on.',
optional => 1
},
},
},
},
@ -127,8 +139,13 @@ __PACKAGE__->register_method ({
my ($param) = @_;
my $skipsmart = $param->{skipsmart} // 0;
my $include_partitions = $param->{'include-partitions'} // 0;
my $disks = PVE::Diskmanage::get_disks(undef, $skipsmart);
my $disks = PVE::Diskmanage::get_disks(
undef,
$skipsmart,
$include_partitions
);
my $type = $param->{type} // '';
my $result = [];