]>
git.proxmox.com Git - pve-firewall.git/blob - src/PVE/API2/Firewall/VM.pm
1 package PVE
::API2
::Firewall
::VM
;
5 use PVE
::JSONSchema
qw(get_standard_option);
9 use Data
::Dumper
; # fixme: remove
11 use base
qw(PVE::RESTHandler);
13 __PACKAGE__-
>register_method({
17 permissions
=> { user
=> 'all' },
18 description
=> "Directory index.",
20 additionalProperties
=> 0,
22 node
=> get_standard_option
('pve-node'),
23 vmid
=> get_standard_option
('pve-vmid'),
32 links
=> [ { rel
=> 'child', href
=> "{name}" } ],
39 { name
=> 'options' },
45 __PACKAGE__-
>register_method({
49 description
=> "List VM firewall rules.",
52 additionalProperties
=> 0,
54 node
=> get_standard_option
('pve-node'),
55 vmid
=> get_standard_option
('pve-vmid'),
68 my $vmid = $param->{vmid
};
70 my $vmlist = PVE
::Cluster
::get_vmlist
();
72 die "no such VM ('$vmid')\n"
73 if !($vmlist && $vmlist->{ids
} && defined($vmlist->{ids
}->{$vmid}));
75 my $vmfw_conf = PVE
::Firewall
::load_vmfw_conf
($vmid);
77 my $rules = $vmfw_conf->{rules
} || [];
79 my $digest = $vmfw_conf->{digest
};
84 foreach my $rule (@$rules) {
85 push @$res, PVE
::Firewall
::cleanup_fw_rule
($rule, $digest, $ind++);
91 __PACKAGE__-
>register_method({
92 name
=> 'get_options',
95 description
=> "Get host firewall options.",
98 additionalProperties
=> 0,
100 node
=> get_standard_option
('pve-node'),
101 vmid
=> get_standard_option
('pve-vmid'),
111 my $vmid = $param->{vmid
};
113 my $vmlist = PVE
::Cluster
::get_vmlist
();
115 die "no such VM ('$vmid')\n"
116 if !($vmlist && $vmlist->{ids
} && defined($vmlist->{ids
}->{$vmid}));
118 my $vmfw_conf = PVE
::Firewall
::load_vmfw_conf
($vmid);
120 my $options = $vmfw_conf->{options
} || {};
122 my $digest = $vmfw_conf->{digest
};
124 $options->{digest
} = $digest;