This parameter is useful for restoring the replication status.
It is also corrected if it is missing 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


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to