From 18c369255da64d14f14a4c030d5fb1acf323b279 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 21 Jun 2017 11:43:24 +0200 Subject: [PATCH] PVE::ReplicationConfig::switch_replication_job_target - new helper moved from PVE::QemuMigrate --- PVE/ReplicationConfig.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm index 5ad1f9b..51cfe81 100644 --- a/PVE/ReplicationConfig.pm +++ b/PVE/ReplicationConfig.pm @@ -223,6 +223,24 @@ sub find_local_replication_job { return undef; } +# switch local replication job target +sub switch_replication_job_target { + my ($vmid, $old_target, $new_target) = @_; + + my $transfer_job = sub { + my $cfg = PVE::ReplicationConfig->new(); + my $jobcfg = find_local_replication_job($cfg, $vmid, $old_target); + + return if !$jobcfg; + + $jobcfg->{target} = $new_target; + + $cfg->write(); + }; + + lock($transfer_job); +}; + sub delete_job { my ($jobid) = @_; -- 2.39.2