1 package PVE
::Network
::Plugin
;
12 use base
qw(PVE::SectionConfig);
14 PVE
::Cluster
::cfs_register_file
('network/transports.cfg',
15 sub { __PACKAGE__-
>parse_config(@_); },
16 sub { __PACKAGE__-
>write_config(@_); });
22 description
=> "Plugin type.",
23 type
=> 'string', format
=> 'pve-configid',
28 minimum
=> 1, maximum
=> 4096,
29 description
=> 'Uplink interface',
38 sub parse_section_header
{
39 my ($class, $line) = @_;
41 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
42 my ($type, $transportid) = (lc($1), $2);
43 my $errmsg = undef; # set if you want to skip whole section
44 eval { PVE
::JSONSchema
::pve_verify_configid
($type); };
46 my $config = {}; # to return additional attributes
47 return ($type, $transportid, $errmsg, $config);
52 sub generate_network_config
{
53 my ($class, $plugin_config, $node, $data, $ctime) = @_;
55 die "please implement inside plugin";
59 sub parse_tag_number_or_range
{
60 my ($str, $max, $tag) = @_;
62 my @elements = split(/,/, $str);
66 die "extraneous commas in list\n" if $str ne join(',', @elements);
67 foreach my $item (@elements) {
68 if ($item =~ m/^([0-9]+)-([0-9]+)$/) {
70 my ($port1, $port2) = ($1, $2);
71 die "invalid port '$port1'\n" if $port1 > $max;
72 die "invalid port '$port2'\n" if $port2 > $max;
73 die "backwards range '$port1:$port2' not allowed, did you mean '$port2:$port1'?\n" if $port1 > $port2;
75 if ($tag && $tag >= $port1 && $tag <= $port2){
80 } elsif ($item =~ m/^([0-9]+)$/) {
83 die "invalid port '$port'\n" if $port > $max;
85 if ($tag && $tag == $port){
91 die "tag $tag is not allowed" if $tag && !$allowed;
93 return (scalar(@elements) > 1);