add type and skipsmart to /nodes/NODE/disks/list
so that we can use it for a generic disk selector this mirrors the functionality we have in /nodes/NODE/ceph/disks api call (which we can deprecate then) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
committed by
Dietmar Maurer
parent
8b6842caa2
commit
83bbd6f5a1
@ -67,6 +67,18 @@ __PACKAGE__->register_method ({
|
|||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
node => get_standard_option('pve-node'),
|
node => get_standard_option('pve-node'),
|
||||||
|
skipsmart => {
|
||||||
|
description => "Skip smart checks.",
|
||||||
|
type => 'boolean',
|
||||||
|
optional => 1,
|
||||||
|
default => 0,
|
||||||
|
},
|
||||||
|
type => {
|
||||||
|
description => "Only list specific types of disks.",
|
||||||
|
type => 'string',
|
||||||
|
enum => ['unused', 'journal_disks'],
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
returns => {
|
returns => {
|
||||||
@ -93,12 +105,23 @@ __PACKAGE__->register_method ({
|
|||||||
code => sub {
|
code => sub {
|
||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
my $disks = PVE::Diskmanage::get_disks();
|
my $skipsmart = $param->{skipsmart} // 0;
|
||||||
|
|
||||||
|
my $disks = PVE::Diskmanage::get_disks(undef, $skipsmart);
|
||||||
|
|
||||||
|
my $type = $param->{type} // '';
|
||||||
my $result = [];
|
my $result = [];
|
||||||
|
|
||||||
foreach my $disk (sort keys %$disks) {
|
foreach my $disk (sort keys %$disks) {
|
||||||
my $entry = $disks->{$disk};
|
my $entry = $disks->{$disk};
|
||||||
|
if ($type eq 'journal_disks') {
|
||||||
|
next if $entry->{osdid} >= 0;
|
||||||
|
next if !$entry->{gpt};
|
||||||
|
} elsif ($type eq 'unused') {
|
||||||
|
next if $entry->{used};
|
||||||
|
} elsif ($type ne '') {
|
||||||
|
die "internal error"; # should not happen
|
||||||
|
}
|
||||||
push @$result, $entry;
|
push @$result, $entry;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
Reference in New Issue
Block a user