From: Dietmar Maurer Date: Tue, 1 Apr 2014 08:25:25 +0000 (+0200) Subject: start cluster wide firewall API X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=commitdiff_plain;h=b4366f0078a37b8542dbeca999dc39cbd4a00f7f start cluster wide firewall API --- diff --git a/src/PVE/API2/Firewall/Cluster.pm b/src/PVE/API2/Firewall/Cluster.pm new file mode 100644 index 0000000..2296baa --- /dev/null +++ b/src/PVE/API2/Firewall/Cluster.pm @@ -0,0 +1,47 @@ +package PVE::API2::Firewall::Cluster; + +use strict; +use warnings; +use PVE::JSONSchema qw(get_standard_option); + +use PVE::Firewall; +use PVE::API2::Firewall::Groups; + +use Data::Dumper; # fixme: remove + +use base qw(PVE::RESTHandler); + +__PACKAGE__->register_method ({ + subclass => "PVE::API2::Firewall::Groups", + path => 'groups', +}); + +__PACKAGE__->register_method({ + name => 'index', + path => '', + method => 'GET', + permissions => { user => 'all' }, + description => "Directory index.", + parameters => { + additionalProperties => 0, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => {}, + }, + links => [ { rel => 'child', href => "{name}" } ], + }, + code => sub { + my ($param) = @_; + + my $result = [ + { name => 'rules' }, + { name => 'options' }, + { name => 'groups' }, + { name => 'netgroups' }, + ]; + + return $result; + }}); diff --git a/src/PVE/API2/Firewall/Groups.pm b/src/PVE/API2/Firewall/Groups.pm index 241585b..6a07fd0 100644 --- a/src/PVE/API2/Firewall/Groups.pm +++ b/src/PVE/API2/Firewall/Groups.pm @@ -16,12 +16,8 @@ __PACKAGE__->register_method({ path => '', method => 'GET', description => "List security groups.", - proxyto => 'node', parameters => { additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - }, }, returns => { type => 'array', @@ -54,11 +50,9 @@ __PACKAGE__->register_method({ path => '{group}', method => 'GET', description => "List security groups rules.", - proxyto => 'node', parameters => { additionalProperties => 0, properties => { - node => get_standard_option('pve-node'), group => { description => "Security group name.", type => 'string', @@ -102,11 +96,9 @@ __PACKAGE__->register_method({ path => '{group}/{pos}', method => 'GET', description => "Get single rule data.", - proxyto => 'node', parameters => { additionalProperties => 0, properties => { - node => get_standard_option('pve-node'), group => { description => "Security group name.", type => 'string', @@ -150,12 +142,10 @@ __PACKAGE__->register_method({ path => '{group}', method => 'POST', description => "Create new rule.", - proxyto => 'node', protected => 1, parameters => { additionalProperties => 0, properties => PVE::Firewall::add_rule_properties({ - node => get_standard_option('pve-node'), group => { description => "Security group name.", type => 'string', @@ -189,12 +179,10 @@ __PACKAGE__->register_method({ path => '{group}/{pos}', method => 'PUT', description => "Modify rule data.", - proxyto => 'node', protected => 1, parameters => { additionalProperties => 0, properties => PVE::Firewall::add_rule_properties({ - node => get_standard_option('pve-node'), group => { description => "Security group name.", type => 'string', @@ -250,12 +238,10 @@ __PACKAGE__->register_method({ path => '{group}/{pos}', method => 'DELETE', description => "Delete rule.", - proxyto => 'node', protected => 1, parameters => { additionalProperties => 0, properties => { - node => get_standard_option('pve-node'), group => { description => "Security group name.", type => 'string', diff --git a/src/PVE/API2/Firewall/Makefile b/src/PVE/API2/Firewall/Makefile index 78fe63e..fbcb6d3 100644 --- a/src/PVE/API2/Firewall/Makefile +++ b/src/PVE/API2/Firewall/Makefile @@ -1,4 +1,5 @@ LIB_SOURCES= \ + Cluster.pm \ Host.pm \ VM.pm \ Groups.pm