[pve-devel] [PATCH v2 manager 7/8] simplify get_included_vmids function
Fabian Ebner
f.ebner at proxmox.com
Thu Oct 22 12:30:16 CEST 2020
by collecting all the guest IDs first.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
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
More information about the pve-devel
mailing list