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',
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
+ },
},
},
},
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 = [];
}
sub get_disks {
- my ($disks, $nosmart) = @_;
+ my ($disks, $nosmart, $include_partitions) = @_;
my $disklist = {};
my $mounted = {};
my $lvm_based_osd = defined($partitions->{$part});
$partitions->{$part}->{devpath} = "$partpath/$part";
+ $partitions->{$part}->{parent} = "$devpath";
$partitions->{$part}->{gpt} = $data->{gpt};
$partitions->{$part}->{size} =
get_sysdir_size("$sysdir/$part") // 0;
});
my $used = $determine_usage->($devpath, $sysdir, 0);
- foreach my $part (sort keys %{$partitions}) {
- next if $partitions->{$part}->{used} eq 'partition';
- $used //= $partitions->{$part}->{used};
+ if (!$include_partitions) {
+ foreach my $part (sort keys %{$partitions}) {
+ next if $partitions->{$part}->{used} eq 'partition';
+ $used //= $partitions->{$part}->{used};
+ }
}
$used //= 'partitions' if scalar(keys %{$partitions});
# multipath, software raid, etc.
$disklist->{$dev}->{osdencrypted} = $osdencrypted if $osdid != -1;
$disklist->{$dev}->{db} = $db_count if $db_count;
$disklist->{$dev}->{wal} = $wal_count if $wal_count;
+
+ if ($include_partitions) {
+ foreach my $part (keys %{$partitions}) {
+ $disklist->{$part} = $partitions->{$part};
+ }
+ }
});
return $disklist;