all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Leo Nunner <l.nunner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet with members
Date: Mon, 24 Oct 2022 12:02:01 +0200	[thread overview]
Message-ID: <20221024100202.44338-2-l.nunner@proxmox.com> (raw)
In-Reply-To: <20221024100202.44338-1-l.nunner@proxmox.com>

Currently, trying to delete a non-empty IPSet will throw an error.
Manually deleting all members of the set might be a time-consuming
process, which the force parameter allows to bypass.

Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
---
 src/PVE/API2/Firewall/IPSet.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Firewall/IPSet.pm b/src/PVE/API2/Firewall/IPSet.pm
index ec9326f..a5f69e9 100644
--- a/src/PVE/API2/Firewall/IPSet.pm
+++ b/src/PVE/API2/Firewall/IPSet.pm
@@ -132,6 +132,11 @@ sub register_delete_ipset {
     my $properties = $class->additional_parameters();
 
     $properties->{name} = get_standard_option('ipset-name');
+    $properties->{force} = {
+	type => 'boolean',
+	optional => 1,
+	description => 'Delete all members of the IPSet, if there are any.',
+    };
 
     $class->register_method({
 	name => 'delete_ipset',
@@ -154,7 +159,7 @@ sub register_delete_ipset {
 		my ($cluster_conf, $fw_conf, $ipset) = $class->load_config($param);
 
 		die "IPSet '$param->{name}' is not empty\n"
-		    if scalar(@$ipset);
+		    if scalar(@$ipset) && !$param->{force};
 
 		$class->save_ipset($param, $fw_conf, undef);
 
-- 
2.30.2





  reply	other threads:[~2022-10-24 10:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24 10:02 [pve-devel] [PATCH firewall manager] delete IPset " Leo Nunner
2022-10-24 10:02 ` Leo Nunner [this message]
2022-11-16 19:28   ` [pve-devel] applied: [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet " Thomas Lamprecht
2022-10-24 10:02 ` [pve-devel] [PATCH manager] fix #4268: add checkbox for force deletion of IPSet Leo Nunner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221024100202.44338-2-l.nunner@proxmox.com \
    --to=l.nunner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal