]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/API2/Disks.pm
add FileRestore API for PBS
[pve-storage.git] / PVE / API2 / Disks.pm
index 86d8fcf4c8bcd93ee3cefc279af71700c6df9fb7..33bca7655b54f874e5a730ff88d665e05b8d3905 100644 (file)
@@ -3,15 +3,18 @@ package PVE::API2::Disks;
 use strict;
 use warnings;
 
-use PVE::SafeSyslog;
-use PVE::Diskmanage;
 use HTTP::Status qw(:constants);
+
+use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
+use PVE::SafeSyslog;
 
+use PVE::API2::Disks::Directory;
 use PVE::API2::Disks::LVM;
+use PVE::API2::Disks::LVMThin;
+use PVE::API2::Disks::ZFS;
 
 use PVE::RESTHandler;
-
 use base qw(PVE::RESTHandler);
 
 __PACKAGE__->register_method ({
@@ -19,6 +22,21 @@ __PACKAGE__->register_method ({
    path => 'lvm',
 });
 
+__PACKAGE__->register_method ({
+   subclass => "PVE::API2::Disks::LVMThin",
+   path => 'lvmthin',
+});
+
+__PACKAGE__->register_method ({
+   subclass => "PVE::API2::Disks::Directory",
+   path => 'directory',
+});
+
+__PACKAGE__->register_method ({
+   subclass => "PVE::API2::Disks::ZFS",
+   path => 'zfs',
+});
+
 __PACKAGE__->register_method ({
     name => 'index',
     path => '',
@@ -48,7 +66,10 @@ __PACKAGE__->register_method ({
            { name => 'initgpt' },
            { name => 'smart' },
            { name => 'lvm' },
-           ];
+           { name => 'lvmthin' },
+           { name => 'directory' },
+           { name => 'zfs' },
+       ];
 
        return $result;
     }});
@@ -61,12 +82,21 @@ __PACKAGE__->register_method ({
     protected => 1,
     proxyto => 'node',
     permissions => {
-       check => ['perm', '/', ['Sys.Audit', 'Datastore.Audit'], any => 1],
+       check => ['or',
+           ['perm', '/', ['Sys.Audit', 'Datastore.Audit'], any => 1],
+           ['perm', '/nodes/{node}', ['Sys.Audit', 'Datastore.Audit'], any => 1],
+       ],
     },
     parameters => {
        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',
@@ -99,6 +129,12 @@ __PACKAGE__->register_method ({
                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
+               },
            },
        },
     },
@@ -106,8 +142,13 @@ __PACKAGE__->register_method ({
        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 = [];
@@ -116,7 +157,10 @@ __PACKAGE__->register_method ({
            my $entry = $disks->{$disk};
            if ($type eq 'journal_disks') {
                next if $entry->{osdid} >= 0;
-               next if !$entry->{gpt};
+               if (my $usage = $entry->{used}) {
+                   next if !($usage eq 'partitions' && $entry->{gpt}
+                       || $usage eq 'LVM');
+               }
            } elsif ($type eq 'unused') {
                next if $entry->{used};
            } elsif ($type ne '') {