+ $class->register_method({
+ name => 'log',
+ path => 'log',
+ method => 'GET',
+ description => "Read firewall log",
+ proxyto => 'node',
+ permissions => {
+ check => ['perm', '/vms/{vmid}', [ 'VM.Console' ]],
+ },
+ protected => 1,
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ vmid => get_standard_option('pve-vmid'),
+ start => {
+ type => 'integer',
+ minimum => 0,
+ optional => 1,
+ },
+ limit => {
+ type => 'integer',
+ minimum => 0,
+ optional => 1,
+ },
+ },
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ n => {
+ description=> "Line number",
+ type=> 'integer',
+ },
+ t => {
+ description=> "Line text",
+ type => 'string',
+ }
+ }
+ }
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $user = $rpcenv->get_user();
+ my $vmid = $param->{vmid};
+
+ my ($count, $lines) = PVE::Tools::dump_logfile("/var/log/pve-firewall.log",
+ $param->{start}, $param->{limit},
+ "^$vmid ");
+
+ $rpcenv->set_result_attrib('total', $count);
+
+ return $lines;
+ }});
+}
+
+package PVE::API2::Firewall::VM;
+
+use strict;
+use warnings;
+
+use base qw(PVE::API2::Firewall::VMBase);
+
+__PACKAGE__->register_method ({
+ subclass => "PVE::API2::Firewall::VMRules",
+ path => 'rules',
+});
+
+__PACKAGE__->register_method ({
+ subclass => "PVE::API2::Firewall::VMAliases",
+ path => 'aliases',
+});