From 83bbd6f5a1162eb201a536c4e4d6e75dbc1b0be5 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 30 Jul 2018 10:26:01 +0200 Subject: [PATCH] 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 --- PVE/API2/Disks.pm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/PVE/API2/Disks.pm b/PVE/API2/Disks.pm index 7ae81eb..86d8fcf 100644 --- a/PVE/API2/Disks.pm +++ b/PVE/API2/Disks.pm @@ -67,6 +67,18 @@ __PACKAGE__->register_method ({ additionalProperties => 0, properties => { 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 => { @@ -93,12 +105,23 @@ __PACKAGE__->register_method ({ code => sub { 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 = []; foreach my $disk (sort keys %$disks) { 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; } return $result;