1 package PVE
::Network
::Transport
::Plugin
;
11 use PVE
::JSONSchema
qw(get_standard_option);
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',
26 transport
=> get_standard_option
('pve-transport-id',
27 { completion
=> \
&PVE
::Network
::Transport
::complete_transport
}),
35 sub parse_section_header
{
36 my ($class, $line) = @_;
38 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
39 my ($type, $transportid) = (lc($1), $2);
40 my $errmsg = undef; # set if you want to skip whole section
41 eval { PVE
::JSONSchema
::pve_verify_configid
($type); };
43 my $config = {}; # to return additional attributes
44 return ($type, $transportid, $errmsg, $config);
49 sub generate_network_config
{
50 my ($class, $plugin_config, $node, $data, $ctime) = @_;
52 die "please implement inside plugin";
56 sub parse_tag_number_or_range
{
57 my ($str, $max, $tag) = @_;
59 my @elements = split(/,/, $str);
63 die "extraneous commas in list\n" if $str ne join(',', @elements);
64 foreach my $item (@elements) {
65 if ($item =~ m/^([0-9]+)-([0-9]+)$/) {
67 my ($port1, $port2) = ($1, $2);
68 die "invalid port '$port1'\n" if $port1 > $max;
69 die "invalid port '$port2'\n" if $port2 > $max;
70 die "backwards range '$port1:$port2' not allowed, did you mean '$port2:$port1'?\n" if $port1 > $port2;
72 if ($tag && $tag >= $port1 && $tag <= $port2){
77 } elsif ($item =~ m/^([0-9]+)$/) {
80 die "invalid port '$port'\n" if $port > $max;
82 if ($tag && $tag == $port){
88 die "tag $tag is not allowed" if $tag && !$allowed;
90 return (scalar(@elements) > 1);