[pve-devel] [PATCH storage 3/8] add type and skipsmart to /nodes/NODE/disks/list

Dominik Csapak d.csapak at proxmox.com
Mon Jul 30 10:26:01 CEST 2018


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 at proxmox.com>
---
 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..9d437d0 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;
-- 
2.11.0





More information about the pve-devel mailing list