From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A08C21FF15E for <inbox@lore.proxmox.com>; Tue, 11 Feb 2025 17:08:53 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 57880314C; Tue, 11 Feb 2025 17:08:37 +0100 (CET) From: Daniel Kral <d.kral@proxmox.com> To: pve-devel@lists.proxmox.com Date: Tue, 11 Feb 2025 17:07:55 +0100 Message-Id: <20250211160825.254167-2-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250211160825.254167-1-d.kral@proxmox.com> References: <20250211160825.254167-1-d.kral@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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. [status.pm] Subject: [pve-devel] [PATCH pve-storage v2 1/5] api: {upload, download}_url: factor out common parameter hash accesses X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> Minor cleanup to reduce the amount of `$param->{...}` to variables in the upload and download url API handler. Signed-off-by: Daniel Kral <d.kral@proxmox.com> --- changes since v1: - new! src/PVE/API2/Storage/Status.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index e9a451c..c854b53 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -438,8 +438,8 @@ __PACKAGE__->register_method ({ my $cfg = PVE::Storage::config(); - my $node = $param->{node}; - my $scfg = PVE::Storage::storage_check_enabled($cfg, $param->{storage}, $node); + my ($node, $storage) = $param->@{qw(node storage)}; + my $scfg = PVE::Storage::storage_check_enabled($cfg, $storage, $node); die "can't upload to storage type '$scfg->{type}'\n" if !defined($scfg->{path}); @@ -461,24 +461,24 @@ __PACKAGE__->register_method ({ if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) { raise_param_exc({ filename => "wrong file extension" }); } - $path = PVE::Storage::get_iso_dir($cfg, $param->{storage}); + $path = PVE::Storage::get_iso_dir($cfg, $storage); } elsif ($content eq 'vztmpl') { if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) { raise_param_exc({ filename => "wrong file extension" }); } - $path = PVE::Storage::get_vztmpl_dir($cfg, $param->{storage}); + $path = PVE::Storage::get_vztmpl_dir($cfg, $storage); } elsif ($content eq 'import') { if ($filename !~ m!${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::UPLOAD_IMPORT_EXT_RE_1$!) { raise_param_exc({ filename => "invalid filename or wrong extension" }); } $isOva = 1; - $path = PVE::Storage::get_import_dir($cfg, $param->{storage}); + $path = PVE::Storage::get_import_dir($cfg, $storage); } else { raise_param_exc({ content => "upload content type '$content' not allowed" }); } - die "storage '$param->{storage}' does not support '$content' content\n" + die "storage '$storage' does not support '$content' content\n" if !$scfg->{content}->{$content}; my $dest = "$path/$filename"; @@ -498,9 +498,9 @@ __PACKAGE__->register_method ({ my @remcmd = ('/usr/bin/ssh', $ssh_options->@*, $remip, '--'); eval { # activate remote storage - run_command([@remcmd, '/usr/sbin/pvesm', 'status', '--storage', $param->{storage}]); + run_command([@remcmd, '/usr/sbin/pvesm', 'status', '--storage', $storage]); }; - die "can't activate storage '$param->{storage}' on node '$node': $@\n" if $@; + die "can't activate storage '$storage' on node '$node': $@\n" if $@; run_command( [@remcmd, '/bin/mkdir', '-p', '--', PVE::Tools::shell_quote($dirname)], @@ -511,7 +511,7 @@ __PACKAGE__->register_method ({ $err_cleanup = sub { run_command([@remcmd, 'rm', '-f', '--', $dest]) }; } else { - PVE::Storage::activate_storage($cfg, $param->{storage}); + PVE::Storage::activate_storage($cfg, $storage); File::Path::make_path($dirname); $cmd = ['cp', '--', $tmpfilename, $dest]; } @@ -687,7 +687,7 @@ __PACKAGE__->register_method({ $isOva = 1; } - $path = PVE::Storage::get_import_dir($cfg, $param->{storage}); + $path = PVE::Storage::get_import_dir($cfg, $storage); } else { raise_param_exc({ content => "upload content-type '$content' is not allowed" }); } -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel