-__PACKAGE__->register_method({
- name => 'enablevmfw',
- path => 'enablevmfw',
- method => 'POST',
- parameters => {
- additionalProperties => 0,
- properties => {
- vmid => get_standard_option('pve-vmid'),
- netid => {
- type => 'string',
- optional => 1
- },
- },
- },
- returns => { type => 'null' },
- code => sub {
- my ($param) = @_;
-
- # test if VM exists
- my $vmid = $param->{vmid};
- my $netid = $param->{netid};
-
- my $conf = PVE::QemuServer::load_config($vmid);
-
- foreach my $opt (keys %$conf) {
- next if $opt !~ m/^net(\d+)$/;
- my $net = PVE::QemuServer::parse_net($conf->{$opt});
- next if !$net;
- next if $netid && $opt != $netid;
- PVE::Firewall::generate_tap_rules($net, $opt, $vmid);
- }
-
- return undef;
- }});
-
-__PACKAGE__->register_method({
- name => 'disablevmfw',
- path => 'disablevmfw',
- method => 'POST',
- parameters => {
- additionalProperties => 0,
- properties => {
- vmid => get_standard_option('pve-vmid'),
- netid => {
- type => 'string',
- optional => 1
- },
-
- },
- },
- returns => { type => 'null' },
- code => sub {
- my ($param) = @_;
-
- # test if VM exists
- my $vmid = $param->{vmid};
- my $netid = $param->{netid};
-
- my $conf = PVE::QemuServer::load_config($vmid);
-
- foreach my $opt (keys %$conf) {
- next if $opt !~ m/^net(\d+)$/;
- my $net = PVE::QemuServer::parse_net($conf->{$opt});
- next if !$net;
- next if $netid && $opt != $netid;
- PVE::Firewall::flush_tap_rules($net, $opt, $vmid);
- }
-
- return undef;
- }});
-
-__PACKAGE__->register_method({
- name => 'enablehostfw',
- path => 'enablehostfw',
- method => 'POST',
- parameters => {
- additionalProperties => 0,
- properties => {},
- },
- returns => { type => 'null' },
-
- code => sub {
- my ($param) = @_;
-
- PVE::Firewall::enablehostfw();
-
- return undef;
- }});
-
-__PACKAGE__->register_method({
- name => 'disablehostfw',
- path => 'disablehostfw',
- method => 'POST',
- parameters => {
- additionalProperties => 0,
- properties => {},
- },
- returns => { type => 'null' },
-
- code => sub {
- my ($param) = @_;
-
- PVE::Firewall::disablehostfw();
-
- return undef;
- }});
-