]> git.proxmox.com Git - pve-storage.git/commitdiff
add 'single' raidlevel for zfs
authorDominik Csapak <d.csapak@proxmox.com>
Wed, 8 Aug 2018 08:20:07 +0000 (10:20 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 8 Aug 2018 10:00:18 +0000 (12:00 +0200)
the syntax for creating a pool with a single disk is
not the same as for mirror, so let the user select it
explicitely

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/API2/Disks/ZFS.pm

index 7531af0b71c7e69aa8818e2a7b7513af6e2e56ab..ad6da236c089984b62edcdc65e7f4f846f7c8b55 100644 (file)
@@ -237,8 +237,8 @@ __PACKAGE__->register_method ({
            name => get_standard_option('pve-storage-id'),
            raidlevel => {
                type => 'string',
-               description => 'The RAID level to use, for single disk, use mirror.',
-               enum => ['mirror', 'raid10', 'raidz', 'raidz2', 'raidz3'],
+               description => 'The RAID level to use.',
+               enum => ['single', 'mirror', 'raid10', 'raidz', 'raidz2', 'raidz3'],
            },
            devices => {
                type => 'string', format => 'string-list',
@@ -294,7 +294,8 @@ __PACKAGE__->register_method ({
 
        my $numdisks = scalar(@$devs);
        my $mindisks = {
-           mirror => 1,
+           single => 1,
+           mirror => 2,
            raid10 => 4,
            raidz => 3,
            raidz2 => 4,
@@ -305,6 +306,9 @@ __PACKAGE__->register_method ({
        die "raid10 needs an even number of disks\n"
            if $raidlevel eq 'raid10' && $numdisks % 2 != 0;
 
+       die "please give only one disk for single disk mode\n"
+           if $raidlevel eq 'single' && $numdisks > 1;
+
        die "$raidlevel needs at least $mindisks->{$raidlevel} disks\n"
            if $numdisks < $mindisks->{$raidlevel};
 
@@ -318,6 +322,8 @@ __PACKAGE__->register_method ({
                    for (my $i = 0; $i < @$devs; $i+=2) {
                        push @$cmd, 'mirror', $devs->[$i], $devs->[$i+1];
                    }
+               } elsif ($raidlevel eq 'single') {
+                   push @$cmd, $devs->[0];
                } else {
                    push @$cmd, $raidlevel, @$devs;
                }