]>
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
::Rules
;
10 use PVE
::API2
::Firewall
::Groups
;
11 use PVE
::API2
::Firewall
::IPSet
;
15 use Data
::Dumper
; # fixme: remove
17 use base
qw(PVE::RESTHandler);
19 __PACKAGE__-
>register_method ({
20 subclass
=> "PVE::API2::Firewall::Groups",
24 __PACKAGE__-
>register_method ({
25 subclass
=> "PVE::API2::Firewall::ClusterRules",
29 __PACKAGE__-
>register_method ({
30 subclass
=> "PVE::API2::Firewall::ClusterIPSetList",
34 __PACKAGE__-
>register_method({
38 permissions
=> { user
=> 'all' },
39 description
=> "Directory index.",
41 additionalProperties
=> 0,
49 links
=> [ { rel
=> 'child', href
=> "{name}" } ],
56 { name
=> 'options' },
65 __PACKAGE__-
>register_method({
66 name
=> 'get_options',
69 description
=> "Get Firewall options.",
71 additionalProperties
=> 0,
75 #additionalProperties => 1,
86 my $cluster_conf = PVE
::Firewall
::load_clusterfw_conf
();
88 my $options = $cluster_conf->{options
};
93 my $option_properties = {
100 my $add_option_properties = sub {
101 my ($properties) = @_;
103 foreach my $k (keys %$option_properties) {
104 $properties->{$k} = $option_properties->{$k};
110 __PACKAGE__-
>register_method({
111 name
=> 'set_options',
114 description
=> "Set Firewall options.",
117 additionalProperties
=> 0,
118 properties
=> &$add_option_properties({
120 type
=> 'string', format
=> 'pve-configid-list',
121 description
=> "A list of settings you want to delete.",
126 returns
=> { type
=> "null" },
130 my $cluster_conf = PVE
::Firewall
::load_clusterfw_conf
();
132 if ($param->{delete}) {
133 foreach my $opt (PVE
::Tools
::split_list
($param->{delete})) {
134 raise_param_exc
({ delete => "no such option '$opt'" })
135 if !$option_properties->{$opt};
136 delete $cluster_conf->{options
}->{$opt};
140 if (defined($param->{enable
})) {
141 $cluster_conf->{options
}->{enable
} = $param->{enable
} ?
1 : 0;
144 PVE
::Firewall
::save_clusterfw_conf
($cluster_conf);
149 __PACKAGE__-
>register_method({
150 name
=> 'get_macros',
153 description
=> "List available macros",
155 additionalProperties
=> 0,
163 description
=> "Macro name.",
167 description
=> "More verbose description (if available).",
178 my ($macros, $descr) = PVE
::Firewall
::get_macros
();
180 foreach my $macro (keys %$macros) {
181 push @$res, { macro => $macro, descr
=> $descr->{$macro} || $macro };