Signed-off-by: Hannes Laimer <h.lai...@proxmox.com> --- PVE/Jobs/Plugin.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/PVE/Jobs/Plugin.pm b/PVE/Jobs/Plugin.pm index 6098360b..4883a193 100644 --- a/PVE/Jobs/Plugin.pm +++ b/PVE/Jobs/Plugin.pm @@ -3,7 +3,7 @@ package PVE::Jobs::Plugin; use strict; use warnings; -use PVE::Cluster qw(cfs_register_file); +use PVE::Cluster qw(cfs_register_file cfs_lock_file cfs_read_file cfs_write_file); use base qw(PVE::SectionConfig); @@ -92,6 +92,23 @@ sub write_config { $class->SUPER::write_config($filename, $cfg); } +sub remove_vmid_from_jobs { + my ($vmid) = @_; + cfs_lock_file('jobs.cfg', undef, sub { + my $jobs_data = cfs_read_file('jobs.cfg'); + while((my $id, my $job) = each (%{$jobs_data->{ids}})){ + next if !defined($job->{vmid}); + $job->{vmid} = join(',', grep { $_ ne $vmid } PVE::Tools::split_list($job->{vmid})); + if ($job->{vmid} eq '') { + delete $jobs_data->{ids}->{$id}; + } else { + $jobs_data->{ids}->{$id} = $job; + } + } + cfs_write_file('jobs.cfg', $jobs_data); + }); +} + sub run { my ($class, $cfg) = @_; # implement in subclass -- 2.30.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel