X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=blobdiff_plain;f=src%2FPVE%2FAPI2%2FFirewall%2FVM.pm;h=3d39978fc3b91ff6b563f1aeccd35e61f0666a72;hp=2ed73d53d91d337d604710e6f1bc0e0f38fd0db3;hb=464f933e74591889a8c9569eee3da71a812c905e;hpb=63c91681ed5073e1e659860a1948ed852e061fee diff --git a/src/PVE/API2/Firewall/VM.pm b/src/PVE/API2/Firewall/VM.pm index 2ed73d5..3d39978 100644 --- a/src/PVE/API2/Firewall/VM.pm +++ b/src/PVE/API2/Firewall/VM.pm @@ -5,11 +5,17 @@ use warnings; use PVE::JSONSchema qw(get_standard_option); use PVE::Cluster; use PVE::Firewall; +use PVE::API2::Firewall::Rules; use Data::Dumper; # fixme: remove use base qw(PVE::RESTHandler); +__PACKAGE__->register_method ({ + subclass => "PVE::API2::Firewall::VMRules", + path => 'rules', +}); + __PACKAGE__->register_method({ name => 'index', path => '', @@ -42,52 +48,6 @@ __PACKAGE__->register_method({ return $result; }}); -__PACKAGE__->register_method({ - name => 'get_rules', - path => 'rules', - method => 'GET', - description => "List VM firewall rules.", - proxyto => 'node', - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - vmid => get_standard_option('pve-vmid'), - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => {}, - }, - }, - code => sub { - my ($param) = @_; - - my $vmid = $param->{vmid}; - - my $vmlist = PVE::Cluster::get_vmlist(); - - die "no such VM ('$vmid')\n" - if !($vmlist && $vmlist->{ids} && defined($vmlist->{ids}->{$vmid})); - - my $vmfw_conf = PVE::Firewall::load_vmfw_conf($vmid); - - my $rules = $vmfw_conf->{rules} || []; - - my $digest = $vmfw_conf->{digest}; - - my $res = []; - - my $ind = 0; - foreach my $rule (@$rules) { - push @$res, PVE::Firewall::cleanup_fw_rule($rule, $digest, $ind++); - } - - return $res; - }}); - __PACKAGE__->register_method({ name => 'get_options', path => 'options',