]>
git.proxmox.com Git - pve-firewall.git/blob - src/PVE/API2/Firewall/Cluster.pm
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
::Groups
;
13 use Data
::Dumper
; # fixme: remove
15 use base
qw(PVE::RESTHandler);
17 __PACKAGE__-
>register_method ({
18 subclass
=> "PVE::API2::Firewall::Groups",
22 __PACKAGE__-
>register_method({
26 permissions
=> { user
=> 'all' },
27 description
=> "Directory index.",
29 additionalProperties
=> 0,
37 links
=> [ { rel
=> 'child', href
=> "{name}" } ],
44 { name
=> 'options' },
46 { name
=> 'netgroups' },
52 __PACKAGE__-
>register_method({
53 name
=> 'get_options',
56 description
=> "Get Firewall options.",
58 additionalProperties
=> 0,
62 #additionalProperties => 1,
73 my $cluster_conf = PVE
::Firewall
::load_clusterfw_conf
();
75 my $options = $cluster_conf->{options
};
80 my $option_properties = {
87 my $add_option_properties = sub {
88 my ($properties) = @_;
90 foreach my $k (keys %$option_properties) {
91 $properties->{$k} = $option_properties->{$k};
97 __PACKAGE__-
>register_method({
98 name
=> 'set_options',
101 description
=> "Set Firewall options.",
103 additionalProperties
=> 0,
104 properties
=> &$add_option_properties({
106 type
=> 'string', format
=> 'pve-configid-list',
107 description
=> "A list of settings you want to delete.",
112 returns
=> { type
=> "null" },
116 my $cluster_conf = PVE
::Firewall
::load_clusterfw_conf
();
118 if ($param->{delete}) {
119 foreach my $opt (PVE
::Tools
::split_list
($param->{delete})) {
120 raise_param_exc
({ delete => "no such option '$opt'" })
121 if !$option_properties->{$opt};
122 delete $cluster_conf->{options
}->{$opt};
126 if (defined($param->{enable
})) {
127 $cluster_conf->{options
}->{enable
} = $param->{enable
} ?
1 : 0;
131 PVE
::Firewall
::save_clusterfw_conf
($cluster_conf);