From: Dietmar Maurer Date: Wed, 21 Jun 2017 09:43:24 +0000 (+0200) Subject: PVE::ReplicationConfig::switch_replication_job_target - new helper X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=18c369255da64d14f14a4c030d5fb1acf323b279;p=pve-guest-common.git PVE::ReplicationConfig::switch_replication_job_target - new helper moved from PVE::QemuMigrate --- 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) = @_;