[pve-devel] [PATCH guest-common 1/5] add list_local_jobs and run_full_removal functions

Fabian Ebner f.ebner at proxmox.com
Wed Oct 14 13:36:24 CEST 2020


helpful for removing replicated volumes when purging a guest.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/Replication.pm       | 11 +++++++++++
 PVE/ReplicationConfig.pm |  7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/PVE/Replication.pm b/PVE/Replication.pm
index 132e8bb..a2138fc 100644
--- a/PVE/Replication.pm
+++ b/PVE/Replication.pm
@@ -425,4 +425,15 @@ sub run_replication {
     return $volumes;
 }
 
+sub run_full_removal {
+    my ($guest_class, $jobcfg) = @_;
+
+    my $start_time = time();
+    my $logfunc = sub { print shift . "\n"; };
+
+    $jobcfg->{remove_job} = 'full';
+
+    run_replication($guest_class, $jobcfg, $start_time, $start_time, $logfunc);
+}
+
 1;
diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
index 66ef842..77905a0 100644
--- a/PVE/ReplicationConfig.pm
+++ b/PVE/ReplicationConfig.pm
@@ -228,6 +228,13 @@ sub find_local_replication_job {
     return undef;
 }
 
+sub list_local_jobs {
+    my ($cfg, $vmid) = @_;
+
+    my @jobs = grep { $_->{type} eq 'local' && $_->{guest} == $vmid } values %{$cfg->{ids}};
+    return \@jobs;
+}
+
 # switch local replication job target
 sub switch_replication_job_target {
     my ($vmid, $old_target, $new_target) = @_;
-- 
2.20.1






More information about the pve-devel mailing list