From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 4ADD29396B for ; Thu, 5 Jan 2023 17:17:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 28A0454AE for ; Thu, 5 Jan 2023 17:17:11 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 5 Jan 2023 17:17:07 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AF8E7452E1 for ; Thu, 5 Jan 2023 17:17:06 +0100 (CET) From: Leo Nunner To: pve-devel@lists.proxmox.com Date: Thu, 5 Jan 2023 17:16:57 +0100 Message-Id: <20230105161658.236402-2-l.nunner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230105161658.236402-1-l.nunner@proxmox.com> References: <20230105161658.236402-1-l.nunner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.025 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [nfsplugin.pm, dirplugin.pm, cifsplugin.pm, plugin.pm] Subject: [pve-devel] [PATCH storage] plugin: change name, separator and error message for dir overrides X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2023 16:17:41 -0000 Rename the "dirs" parameter to "content-dirs". Switch from a "vtype:/dir" format to "vtype=/dir", and remove the misleading error message talking about "absolute" paths. One might expect these to be absolute over the whole system, while in reality they are relative to the mountpoint of the storage. Signed-off-by: Leo Nunner --- PVE/Storage/CIFSPlugin.pm | 2 +- PVE/Storage/DirPlugin.pm | 2 +- PVE/Storage/NFSPlugin.pm | 2 +- PVE/Storage/Plugin.pm | 18 +++++++++--------- test/get_subdir_test.pm | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/PVE/Storage/CIFSPlugin.pm b/PVE/Storage/CIFSPlugin.pm index 4284c35..d238844 100644 --- a/PVE/Storage/CIFSPlugin.pm +++ b/PVE/Storage/CIFSPlugin.pm @@ -128,7 +128,7 @@ sub properties { sub options { return { path => { fixed => 1 }, - dirs => { optional => 1 }, + 'content-dirs' => { optional => 1 }, server => { fixed => 1 }, share => { fixed => 1 }, nodes => { optional => 1 }, diff --git a/PVE/Storage/DirPlugin.pm b/PVE/Storage/DirPlugin.pm index 3c907ca..9e305f5 100644 --- a/PVE/Storage/DirPlugin.pm +++ b/PVE/Storage/DirPlugin.pm @@ -54,7 +54,7 @@ sub properties { sub options { return { path => { fixed => 1 }, - dirs => { optional => 1 }, + 'content-dirs' => { optional => 1 }, nodes => { optional => 1 }, shared => { optional => 1 }, disable => { optional => 1 }, diff --git a/PVE/Storage/NFSPlugin.pm b/PVE/Storage/NFSPlugin.pm index b7e8318..0bdde84 100644 --- a/PVE/Storage/NFSPlugin.pm +++ b/PVE/Storage/NFSPlugin.pm @@ -79,7 +79,7 @@ sub properties { sub options { return { path => { fixed => 1 }, - dirs => { optional => 1 }, + 'content-dirs' => { optional => 1 }, server => { fixed => 1 }, export => { fixed => 1 }, nodes => { optional => 1 }, diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index 5cb3d90..a3aac61 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -181,8 +181,8 @@ my $defaultData = { default => 'metadata', optional => 1, }, - dirs => { - description => "Overrides for default directories", + 'content-dirs' => { + description => "Overrides for default content type directories.", type => "string", format => "pve-dir-override-list", optional => 1, }, @@ -213,7 +213,7 @@ sub valid_content_types { sub dirs_hash_to_string { my $hash = shift; - return join(',', map { "$_:$hash->{$_}" } sort keys %$hash); + return join(',', map { "$_=$hash->{$_}" } sort keys %$hash); } sub default_format { @@ -350,8 +350,8 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override); sub verify_dir_override { my ($value, $noerr) = @_; - if($value =~ m/^([a-z]+):(.+)$/ && - verify_content($1, $noerr) && verify_path($2, $noerr)) { + if($value =~ m/^([a-z]+)=\/.+$/ && + verify_content($1, $noerr)) { return $value; } @@ -429,12 +429,12 @@ sub decode_value { #} return $res; - } elsif ($key eq 'dirs') { + } elsif ($key eq 'content-dirs') { my $valid_content = $def->{content}->[0]; my $res = {}; foreach my $dir (PVE::Tools::split_list($value)) { - my ($content, $path) = split(/:/, $dir, 2); + my ($content, $path) = split(/=/, $dir, 2); if (!$valid_content->{$content}) { warn "storage does not support content type '$content'\n"; @@ -458,7 +458,7 @@ sub encode_value { } elsif ($key eq 'content') { my $res = content_hash_to_string($value) || 'none'; return $res; - } elsif ($key eq 'dirs') { + } elsif ($key eq 'content-dirs') { my $res = dirs_hash_to_string($value); return $res; } @@ -654,7 +654,7 @@ sub get_subdir { die "storage definition has no path\n" if !$path; die "unknown vtype '$vtype'\n" if !exists($vtype_subdirs->{$vtype}); - my $subdir = $scfg->{dirs}->{$vtype} // "/".$vtype_subdirs->{$vtype}; + my $subdir = $scfg->{"content-dirs"}->{$vtype} // "/".$vtype_subdirs->{$vtype}; return $path.$subdir; } diff --git a/test/get_subdir_test.pm b/test/get_subdir_test.pm index 26c08d5..ff42985 100644 --- a/test/get_subdir_test.pm +++ b/test/get_subdir_test.pm @@ -30,8 +30,8 @@ foreach my $type (keys %$vtype_subdirs) { # creates additional tests for overrides foreach my $type (keys %$vtype_subdirs) { my $override = "/${type}_override"; - my $scfg_with_override = { path => '/some/path', dirs => { $type => $override } }; - push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}$scfg_with_override->{dirs}->{$type}" ]; + my $scfg_with_override = { path => '/some/path', 'content-dirs' => { $type => $override } }; + push @$tests, [ $scfg_with_override, $type, "$scfg_with_override->{path}$scfg_with_override->{'content-dirs'}->{$type}" ]; } plan tests => scalar @$tests; -- 2.30.2