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 F19B261B8D for ; Thu, 22 Oct 2020 12:30:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 463981F078 for ; Thu, 22 Oct 2020 12:30:32 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS id BA1511EFC2 for ; Thu, 22 Oct 2020 12:30:29 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7B8FC45ABA for ; Thu, 22 Oct 2020 12:30:29 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 22 Oct 2020 12:30:16 +0200 Message-Id: <20201022103017.19715-8-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201022103017.19715-1-f.ebner@proxmox.com> References: <20201022103017.19715-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.038 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [backupinfo.pm] Subject: [pve-devel] [PATCH v2 manager 7/8] simplify get_included_vmids function 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, 22 Oct 2020 10:30:33 -0000 by collecting all the guest IDs first. Signed-off-by: Fabian Ebner --- PVE/API2/BackupInfo.pm | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/PVE/API2/BackupInfo.pm b/PVE/API2/BackupInfo.pm index 909a5de1..4c461e59 100644 --- a/PVE/API2/BackupInfo.pm +++ b/PVE/API2/BackupInfo.pm @@ -17,30 +17,18 @@ use PVE::VZDump::Common; use base qw(PVE::RESTHandler); -sub map_job_vmids { - my ($job_included_guests, $included_vmids) = @_; - - for my $node_vmids (values %{$job_included_guests}) { - for my $vmid (@{$node_vmids}) { - $included_vmids->{$vmid} = 1; - } - } - - return $included_vmids; -} - sub get_included_vmids { - my $included_vmids = {}; my $vzconf = cfs_read_file('vzdump.cron'); my $all_jobs = $vzconf->{jobs} || []; + my @all_vmids = (); for my $job (@$all_jobs) { my $job_included_guests = PVE::VZDump::get_included_guests($job); - $included_vmids = map_job_vmids($job_included_guests, $included_vmids); + push @all_vmids, ( map { @{$_} } values %{$job_included_guests} ); } - return $included_vmids; + return { map { $_ => 1 } @all_vmids }; } __PACKAGE__->register_method({ -- 2.20.1