[pve-devel] [Patch V5 guest-common 5/7] Add function: swap source and target in replication config

Wolfgang Link w.link at proxmox.com
Wed May 9 14:48:25 CEST 2018


---
 PVE/ReplicationConfig.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
index b6cd514..eb98f78 100644
--- a/PVE/ReplicationConfig.pm
+++ b/PVE/ReplicationConfig.pm
@@ -258,6 +258,19 @@ sub delete_job {
     lock($code);
 }
 
+sub swap_source_target_nolock {
+    my ($jobid) = @_;
+
+    my $cfg = __PACKAGE__->new();
+    my $job = $cfg->{ids}->{$jobid};
+    my $tmp = $job->{source};
+    $job->{source} = $job->{target};
+    $job->{target} = $tmp;
+    $cfg->write();
+
+    return $cfg->{ids}->{$jobid};
+}
+
 package PVE::ReplicationConfig::Cluster;
 
 use base qw(PVE::ReplicationConfig);
-- 
2.11.0




More information about the pve-devel mailing list