* [pve-devel] [PATCH firewall manager] delete IPset with members
@ 2022-10-24 10:02 Leo Nunner
2022-10-24 10:02 ` [pve-devel] [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet " Leo Nunner
2022-10-24 10:02 ` [pve-devel] [PATCH manager] fix #4268: add checkbox for force deletion of IPSet Leo Nunner
0 siblings, 2 replies; 4+ messages in thread
From: Leo Nunner @ 2022-10-24 10:02 UTC (permalink / raw)
To: pve-devel
Currently, deleting an IPSet with members is not possible. The user
first needs to delete all the members individually, and only then can
they delete the IPSet itself. This patch adds a 'force' parameter that
enables the deletion of the IPSet and all its members, allowing this
step to be bypassed.
firewall:
Leo Nunner (1):
fix #4268: add 'force' parameter to delete IPSet with members
src/PVE/API2/Firewall/IPSet.pm | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
manager:
Leo Nunner (1):
fix #4268: add checkbox for force deletion of IPSet
www/manager6/panel/IPSet.js | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet with members
2022-10-24 10:02 [pve-devel] [PATCH firewall manager] delete IPset with members Leo Nunner
@ 2022-10-24 10:02 ` Leo Nunner
2022-11-16 19:28 ` [pve-devel] applied: " Thomas Lamprecht
2022-10-24 10:02 ` [pve-devel] [PATCH manager] fix #4268: add checkbox for force deletion of IPSet Leo Nunner
1 sibling, 1 reply; 4+ messages in thread
From: Leo Nunner @ 2022-10-24 10:02 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH manager] fix #4268: add checkbox for force deletion of IPSet
2022-10-24 10:02 [pve-devel] [PATCH firewall manager] delete IPset with members Leo Nunner
2022-10-24 10:02 ` [pve-devel] [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet " Leo Nunner
@ 2022-10-24 10:02 ` Leo Nunner
1 sibling, 0 replies; 4+ messages in thread
From: Leo Nunner @ 2022-10-24 10:02 UTC (permalink / raw)
To: pve-devel
Expose the 'force' parameter through the UI when deleting an IPSet.
Small OQL imporovement: the member panel now gets cleared
automatically whenever an IPSet is deselected, which is necessary
when deleting a non-empty set.
Signed-off-by: Leo Nunner <l.nunner@proxmox.com>
---
www/manager6/panel/IPSet.js | 32 +++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)
diff --git a/www/manager6/panel/IPSet.js b/www/manager6/panel/IPSet.js
index a4606769..a6146566 100644
--- a/www/manager6/panel/IPSet.js
+++ b/www/manager6/panel/IPSet.js
@@ -46,6 +46,7 @@ Ext.define('PVE.IPSetList', {
var reload = function() {
var oldrec = sm.getSelection()[0];
+ sm.deselect(oldrec);
store.load(function(records, operation, success) {
if (oldrec) {
var rec = store.findRecord('name', oldrec.data.name, 0, false, true, true);
@@ -91,6 +92,30 @@ Ext.define('PVE.IPSetList', {
win.on('destroy', reload);
};
+ var run_delete = function() {
+ var rec = sm.getSelection()[0];
+ if (!rec) {
+ return;
+ }
+ var win = Ext.create('Proxmox.window.Edit', {
+ title: "Delete IPSet '"+ rec.data.name + "'?",
+ url: me.base_url + '/' + rec.data.name,
+ method: 'DELETE',
+ isCreate: true,
+ isRemove: true,
+ items: [
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'force',
+ checked: false,
+ fieldLabel: gettext('Delete members'),
+ },
+ ],
+ });
+ win.show();
+ win.on('destroy', reload);
+ };
+
me.editBtn = new Proxmox.button.Button({
text: gettext('Edit'),
disabled: true,
@@ -127,10 +152,11 @@ Ext.define('PVE.IPSetList', {
},
});
- me.removeBtn = Ext.create('Proxmox.button.StdRemoveButton', {
+ me.removeBtn = Ext.create('Proxmox.button.Button', {
+ text: gettext('Remove'),
+ disabled: true,
selModel: sm,
- baseurl: me.base_url + '/',
- callback: reload,
+ handler: run_delete,
});
Ext.apply(me, {
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied: [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet with members
2022-10-24 10:02 ` [pve-devel] [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet " Leo Nunner
@ 2022-11-16 19:28 ` Thomas Lamprecht
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2022-11-16 19:28 UTC (permalink / raw)
To: Proxmox VE development discussion, Leo Nunner
Am 24/10/2022 um 12:02 schrieb Leo Nunner:
> 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(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-16 19:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 10:02 [pve-devel] [PATCH firewall manager] delete IPset with members Leo Nunner
2022-10-24 10:02 ` [pve-devel] [PATCH firewall 1/1] fix #4268: add 'force' parameter to delete IPSet " Leo Nunner
2022-11-16 19:28 ` [pve-devel] applied: " Thomas Lamprecht
2022-10-24 10:02 ` [pve-devel] [PATCH manager] fix #4268: add checkbox for force deletion of IPSet Leo Nunner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox