From: Dietmar Maurer Date: Wed, 9 Apr 2014 05:15:14 +0000 (+0200) Subject: IPSet: implement rename API X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=commitdiff_plain;h=bc374ca7cfd083a665f07b8902d63754c8c2a6a6 IPSet: implement rename API --- diff --git a/src/PVE/API2/Firewall/IPSet.pm b/src/PVE/API2/Firewall/IPSet.pm index c9372fa..71f6b4c 100644 --- a/src/PVE/API2/Firewall/IPSet.pm +++ b/src/PVE/API2/Firewall/IPSet.pm @@ -355,6 +355,11 @@ sub register_create { description => "IP set name.", type => 'string', }, + rename => { + description => "Rename an existing IPSet.", + type => 'string', + optional => 1, + }, } }, returns => { type => 'null' }, @@ -368,7 +373,15 @@ sub register_create { if $name eq $param->{name}; } - $fw_conf->{ipset}->{$param->{name}} = []; + if ($param->{rename}) { + raise_param_exc({ name => "IPSet '$param->{rename}' does not exists" }) + if !$fw_conf->{ipset}->{$param->{rename}}; + my $data = delete $fw_conf->{ipset}->{$param->{rename}}; + $fw_conf->{ipset}->{$param->{name}} = $data; + } else { + $fw_conf->{ipset}->{$param->{name}} = []; + } + $class->save_config($fw_conf); return undef;