From: Dietmar Maurer Date: Wed, 9 Apr 2014 06:05:51 +0000 (+0200) Subject: define standard option for security group names X-Git-Url: https://git.proxmox.com/?p=pve-firewall.git;a=commitdiff_plain;h=387d0ffce61dcd0264b01165ccb4e4e197af7d76 define standard option for security group names --- diff --git a/src/PVE/API2/Firewall/Groups.pm b/src/PVE/API2/Firewall/Groups.pm index a929236..23b33ef 100644 --- a/src/PVE/API2/Firewall/Groups.pm +++ b/src/PVE/API2/Firewall/Groups.pm @@ -24,10 +24,7 @@ __PACKAGE__->register_method({ items => { type => "object", properties => { - name => { - description => "Security group name.", - type => 'string', - }, + name => get_standard_option('pve-security-group-name'), }, }, links => [ { rel => 'child', href => "{name}" } ], @@ -45,6 +42,7 @@ __PACKAGE__->register_method({ return $res; }}); + __PACKAGE__->register_method ({ subclass => "PVE::API2::Firewall::GroupRules", path => '{group}', diff --git a/src/PVE/API2/Firewall/Rules.pm b/src/PVE/API2/Firewall/Rules.pm index d9ba2f4..4837880 100644 --- a/src/PVE/API2/Firewall/Rules.pm +++ b/src/PVE/API2/Firewall/Rules.pm @@ -302,14 +302,11 @@ package PVE::API2::Firewall::GroupRules; use strict; use warnings; +use PVE::JSONSchema qw(get_standard_option); use base qw(PVE::API2::Firewall::RulesBase); -__PACKAGE__->additional_parameters({ group => { - description => "Security group name.", - type => 'string', - maxLength => 20, # fixme: what length? -}}); +__PACKAGE__->additional_parameters({ group => get_standard_option('pve-security-group-name') }); sub allow_groups { return 0; diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index 1438125..4375f9c 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -52,8 +52,16 @@ PVE::JSONSchema::register_standard_option('ipset-name', { description => "IP set name.", type => 'string', pattern => '[A-Za-z][A-Za-z0-9\-\_]+', - minLength => 2, - maxLength => 20, + minLength => 2, + maxLength => 20, +}); + +PVE::JSONSchema::register_standard_option('pve-security-group-name', { + description => "Security Group name.", + type => 'string', + pattern => '[A-Za-z][A-Za-z0-9\-\_]+', + minLength => 2, + maxLength => 20, }); my $feature_ipset_nomatch = 0;