[pve-devel] [PATCH] Add force parameter for delete replica job.

Wolfgang Link w.link at proxmox.com
Thu Jun 8 12:01:50 CEST 2017


This parameter is helpful if an unsolvable situation occurs or the vmconfig was delete manually.
---
 PVE/API2/ReplicationConfig.pm | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/PVE/API2/ReplicationConfig.pm b/PVE/API2/ReplicationConfig.pm
index e50077c3..12dee54a 100644
--- a/PVE/API2/ReplicationConfig.pm
+++ b/PVE/API2/ReplicationConfig.pm
@@ -198,6 +198,12 @@ __PACKAGE__->register_method ({
 		optional => 1,
 		default => 0,
 	    },
+	    force => {
+		description => "Will remove the jobconfig entry, but will not cleanup.",
+		type => 'boolean',
+		optional => 1,
+		default => 0,
+	    },
 	}
     },
     returns => { type => 'null' },
@@ -210,21 +216,24 @@ __PACKAGE__->register_method ({
 	    my $cfg = PVE::ReplicationConfig->new();
 
 	    my $id = $param->{id};
-
-	    my $jobcfg = $cfg->{ids}->{$id};
-	    die "no such job '$id'\n" if !$jobcfg;
-
-	    if (!$param->{keep} && $jobcfg->{type} eq 'local') {
-		# remove local snapshots and remote volumes
-		$jobcfg->{remove_job} = 'full';
+	    if ($param->{force}) {
+		die "Keep will not work when force is set.\n" if $param->{keep};
+		delete $cfg->{ids}->{$id};
 	    } else {
-		# only remove local snapshots
-		$jobcfg->{remove_job} = 'local';
+		my $jobcfg = $cfg->{ids}->{$id};
+		die "no such job '$id'\n" if !$jobcfg;
+
+		if (!$param->{keep} && $jobcfg->{type} eq 'local') {
+		    # remove local snapshots and remote volumes
+		    $jobcfg->{remove_job} = 'full';
+		} else {
+		    # only remove local snapshots
+		    $jobcfg->{remove_job} = 'local';
+		}
+
+		warn "Replication job removal is a background task and will take some time.\n"
+		    if $rpcenv->{type} eq 'cli';
 	    }
-
-	    warn "Replication job removal is a background task and will take some time.\n"
-		if $rpcenv->{type} eq 'cli';
-
 	    $cfg->write();
 	};
 
-- 
2.11.0





More information about the pve-devel mailing list