]> git.proxmox.com Git - pve-firewall.git/blobdiff - src/PVE/API2/Firewall/Groups.pm
cleanup makefiles, set target dirs per makefile
[pve-firewall.git] / src / PVE / API2 / Firewall / Groups.pm
index e8f211603b687fc9705cb6acdb4ac77f7848bf9c..dfc181c90a2724c8ae19043e366fa4d427036108 100644 (file)
@@ -16,7 +16,7 @@ my $get_security_group_list = sub {
     my ($cluster_conf) = @_;
 
     my $res = [];
-    foreach my $group (keys %{$cluster_conf->{groups}}) {
+    foreach my $group (sort keys %{$cluster_conf->{groups}}) {
        my $data = { 
            group => $group,
        };
@@ -101,6 +101,11 @@ __PACKAGE__->register_method({
            raise_param_exc({ group => "Security group '$param->{rename}' does not exists" }) 
                if !$cluster_conf->{groups}->{$param->{rename}};
 
+           # prevent overwriting an existing group
+           raise_param_exc({ group => "Security group '$param->{group}' does already exist" })
+               if $cluster_conf->{groups}->{$param->{group}} &&
+               $param->{group} ne $param->{rename};
+
            my $data = delete $cluster_conf->{groups}->{$param->{rename}};
            $cluster_conf->{groups}->{$param->{group}} = $data;
            if (my $comment = delete $cluster_conf->{group_comments}->{$param->{rename}}) {