[pve-devel] [PATCH guest-common 2/6] Add config field 'source'.

Wolfgang Link w.link at proxmox.com
Wed Dec 13 15:46:24 CET 2017


This field is usfull to restore the replication state.
Also correct this field if is not present or wrong.
---
 PVE/ReplicationConfig.pm | 6 ++++++
 PVE/ReplicationState.pm  | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
index 51cfe81..b6cd514 100644
--- a/PVE/ReplicationConfig.pm
+++ b/PVE/ReplicationConfig.pm
@@ -79,6 +79,11 @@ my $defaultData = {
 	    default => '*/15',
 	    optional => 1,
 	},
+	source => {
+	    description => "Source of the replication.",
+	    type => 'string', format => 'pve-node',
+	    optional => 1,
+	},
     },
 };
 
@@ -278,6 +283,7 @@ sub options {
 	rate => { optional => 1 },
 	schedule => { optional => 1 },
 	remove_job => { optional => 1 },
+	source => { optional => 1 },
     };
 }
 
diff --git a/PVE/ReplicationState.pm b/PVE/ReplicationState.pm
index 567535a..0851195 100644
--- a/PVE/ReplicationState.pm
+++ b/PVE/ReplicationState.pm
@@ -285,6 +285,11 @@ sub job_status {
 
 	$jobcfg->{next_sync} = $next_sync;
 
+	if (!defined($jobcfg->{source}) || $jobcfg->{source} ne $local_node) {
+	    $jobcfg->{source} = $cfg->{ids}->{$jobid}->{source} = $local_node;
+	    PVE::ReplicationConfig::write($cfg);
+	}
+
 	$jobs->{$jobid} = $jobcfg;
     }
 
-- 
2.11.0





More information about the pve-devel mailing list