]> git.proxmox.com Git - pve-storage.git/commitdiff
add type and skipsmart to /nodes/NODE/disks/list
authorDominik Csapak <d.csapak@proxmox.com>
Mon, 30 Jul 2018 08:26:01 +0000 (10:26 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 2 Aug 2018 08:53:30 +0000 (10:53 +0200)
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>
PVE/API2/Disks.pm

index 7ae81eb0e9c7b8590dbfe079884c917c8756984d..86d8fcf4c8bcd93ee3cefc279af71700c6df9fb7 100644 (file)
@@ -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;