5
0
mirror of git://git.proxmox.com/git/pve-guest-common.git synced 2024-12-23 17:34:10 +03:00

also update sources in switch_replication_job_target

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2020-10-29 14:31:27 +01:00 committed by Fabian Grünbichler
parent 6364fd6385
commit 158c90bf9a

View File

@ -228,23 +228,25 @@ sub find_local_replication_job {
return undef;
}
# switch local replication job target
# makes old_target the new source for all local jobs of this guest
# makes new_target the target for the single local job with target old_target
sub switch_replication_job_target {
my ($vmid, $old_target, $new_target) = @_;
my $transfer_job = sub {
my $update_jobs = sub {
my $cfg = PVE::ReplicationConfig->new();
my $jobcfg = find_local_replication_job($cfg, $vmid, $old_target);
return if !$jobcfg;
$jobcfg->{target} = $new_target;
foreach my $jobcfg (values %{$cfg->{ids}}) {
next if $jobcfg->{guest} ne $vmid;
next if $jobcfg->{type} ne 'local';
$jobcfg->{target} = $new_target if $jobcfg->{target} eq $old_target;
$jobcfg->{source} = $old_target;
}
$cfg->write();
};
lock($transfer_job);
};
lock($update_jobs);
}
sub delete_job {
my ($jobid) = @_;