add auto-generated firewall macro definitions
[pve-docs.git] / gen-pve-firewall-macros-adoc.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use PVE::Firewall;
7
8 my ($pve_fw_parsed_macros, $pve_fw_macro_descr) = PVE::Firewall::get_macros();
9
10 #use Data::Dumper;
11 #print Dumper($pve_fw_macro_descr);
12 #print Dumper($pve_fw_parsed_macros);
13
14 foreach my $name (sort keys %$pve_fw_parsed_macros) {
15 my $descr = $pve_fw_macro_descr->{$name};
16 die "no description for macro '$name'" if !defined($descr);
17 print "[horizontal]\n'$name':: $descr\n\n";
18
19 print "[width=\"100%\",options=\"header\"]\n" .
20 "|===========================================================\n" .
21 "|Action|proto|dport|sport\n";
22
23 my $rules = $pve_fw_parsed_macros->{$name};
24
25 foreach my $rule (@$rules) {
26 print "|$rule->{action}|";
27 print (($rule->{proto} || '') . '|');
28 print (($rule->{dport} || '') . '|');
29 print (($rule->{sport} || '') . "\n");
30 }
31
32 print "|===========================================================\n";
33
34 print "\n";
35 }