]>
git.proxmox.com Git - pve-firewall.git/blob - src/PVE/API2/Firewall/Cluster.pm
5923aa84bd219f33f220a7ba820d6b3b940b5785
1 package PVE
::API2
::Firewall
::Cluster
;
5 use PVE
::Exception
qw(raise raise_param_exc raise_perm_exc);
6 use PVE
::JSONSchema
qw(get_standard_option);
9 use PVE
::API2
::Firewall
::Rules
;
10 use PVE
::API2
::Firewall
::Groups
;
14 use Data
::Dumper
; # fixme: remove
16 use base
qw(PVE::RESTHandler);
18 __PACKAGE__-
>register_method ({
19 subclass
=> "PVE::API2::Firewall::Groups",
23 __PACKAGE__-
>register_method ({
24 subclass
=> "PVE::API2::Firewall::ClusterRules",
28 __PACKAGE__-
>register_method({
32 permissions
=> { user
=> 'all' },
33 description
=> "Directory index.",
35 additionalProperties
=> 0,
43 links
=> [ { rel
=> 'child', href
=> "{name}" } ],
50 { name
=> 'options' },
52 { name
=> 'netgroups' },
58 __PACKAGE__-
>register_method({
59 name
=> 'get_options',
62 description
=> "Get Firewall options.",
64 additionalProperties
=> 0,
68 #additionalProperties => 1,
79 my $cluster_conf = PVE
::Firewall
::load_clusterfw_conf
();
81 my $options = $cluster_conf->{options
};
86 my $option_properties = {
93 my $add_option_properties = sub {
94 my ($properties) = @_;
96 foreach my $k (keys %$option_properties) {
97 $properties->{$k} = $option_properties->{$k};
103 __PACKAGE__-
>register_method({
104 name
=> 'set_options',
107 description
=> "Set Firewall options.",
110 additionalProperties
=> 0,
111 properties
=> &$add_option_properties({
113 type
=> 'string', format
=> 'pve-configid-list',
114 description
=> "A list of settings you want to delete.",
119 returns
=> { type
=> "null" },
123 my $cluster_conf = PVE
::Firewall
::load_clusterfw_conf
();
125 if ($param->{delete}) {
126 foreach my $opt (PVE
::Tools
::split_list
($param->{delete})) {
127 raise_param_exc
({ delete => "no such option '$opt'" })
128 if !$option_properties->{$opt};
129 delete $cluster_conf->{options
}->{$opt};
133 if (defined($param->{enable
})) {
134 $cluster_conf->{options
}->{enable
} = $param->{enable
} ?
1 : 0;
137 PVE
::Firewall
::save_clusterfw_conf
($cluster_conf);