[pve-devel] [PATCH manager 1/7] implement delete parameter for replicationconfig

Dominik Csapak d.csapak at proxmox.com
Tue Jun 13 14:56:00 CEST 2017


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/API2/ReplicationConfig.pm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/PVE/API2/ReplicationConfig.pm b/PVE/API2/ReplicationConfig.pm
index 51edff70..f5523662 100644
--- a/PVE/API2/ReplicationConfig.pm
+++ b/PVE/API2/ReplicationConfig.pm
@@ -160,6 +160,7 @@ __PACKAGE__->register_method ({
 
 	my $id = extract_param($param, 'id');
 	my $digest = extract_param($param, 'digest');
+	my $delete = extract_param($param, 'delete');
 
 	my $code = sub {
 	    my $cfg = PVE::ReplicationConfig->new();
@@ -176,6 +177,19 @@ __PACKAGE__->register_method ({
 		$data->{$k} = $opts->{$k};
 	    }
 
+	    if ($delete) {
+		my $options = $plugin->private()->{options}->{$data->{type}};
+		foreach my $k (PVE::Tools::split_list($delete)) {
+		    my $d = $options->{$k} ||
+			die "no such option '$k'\n";
+		    die "unable to delete required option '$k'\n"
+			if !$d->{optional};
+		    die "unable to delete fixed option '$k'\n"
+			if $d->{fixed};
+		    delete $data->{$k};
+		}
+	    }
+
 	    $cfg->write();
 	};
 
-- 
2.11.0





More information about the pve-devel mailing list