From 8a5ffcd9918ba89e14b64ad81ecaaefce4388679 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 11 Nov 2022 09:22:19 +0100 Subject: [PATCH] disk manage: move "draid-config set only on draid level" assertion so that there is a better code locality and also we avoid forgetting to adapt the check for each specific draid-config parameter if a new one gets added or an existing one changed. Signed-off-by: Thomas Lamprecht --- PVE/API2/Disks/ZFS.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PVE/API2/Disks/ZFS.pm b/PVE/API2/Disks/ZFS.pm index 9651ba1..ca3169d 100644 --- a/PVE/API2/Disks/ZFS.pm +++ b/PVE/API2/Disks/ZFS.pm @@ -363,6 +363,7 @@ __PACKAGE__->register_method ({ my $compression = $param->{compression} // 'on'; my $draid_config = {}; if (exists $param->{'draid-config'}) { + die "draid-config set without using dRAID level\n" if $raidlevel !~ m/^draid/; $draid_config = PVE::JSONSchema::parse_property_string( $draid_config_format, $param->{'draid-config'}); } @@ -431,9 +432,6 @@ __PACKAGE__->register_method ({ die "At least $draidmin disks needed for current dRAID config\n" if $numdisks < $draidmin; - } else { - die "draidspares and/or draiddata set without using dRAID" - if ($draid_spares or $draid_data); } my $code = sub {