]> git.proxmox.com Git - pve-guest-common.git/commitdiff
PVE::ReplicationConfig::switch_replication_job_target - new helper
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 21 Jun 2017 09:43:24 +0000 (11:43 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 21 Jun 2017 09:43:24 +0000 (11:43 +0200)
moved from PVE::QemuMigrate

PVE/ReplicationConfig.pm

index 5ad1f9bb3337b2a42986a1e265f7458cbd4497e2..51cfe81ead08fb702a7bbea214a467644973a16a 100644 (file)
@@ -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) = @_;