use PVE::Tools qw(extract_param);
use PVE::Cluster qw(cfs_read_file cfs_write_file);
use PVE::Network::SDN;
+use PVE::Network::SDN::Zones;
+use PVE::Network::SDN::Zones::Plugin;
use PVE::Network::SDN::Vnets;
use PVE::Network::SDN::VnetPlugin;
}
$cfg->{ids}->{$id} = $opts;
+
+ my $zone_cfg = PVE::Network::SDN::Zones::config();
+ my $zoneid = $cfg->{ids}->{$id}->{zone};
+ my $plugin_config = $zone_cfg->{ids}->{$zoneid};
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ $plugin->verify_tag($opts->{tag});
+
PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg);
PVE::Network::SDN::Vnets::write_config($cfg);
my $opts = PVE::Network::SDN::VnetPlugin->check_config($id, $param, 0, 1);
$cfg->{ids}->{$id} = $opts;
+ my $zone_cfg = PVE::Network::SDN::Zones::config();
+ my $zoneid = $cfg->{ids}->{$id}->{zone};
+ my $plugin_config = $zone_cfg->{ids}->{$zoneid};
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ $plugin->verify_tag($opts->{tag});
+
PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg);
PVE::Network::SDN::Vnets::write_config($cfg);
use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
use base qw(PVE::SectionConfig);
use PVE::JSONSchema qw(get_standard_option);
+use PVE::Exception qw(raise raise_param_exc);
PVE::Cluster::cfs_register_file('sdn/vnets.cfg',
sub { __PACKAGE__->parse_config(@_); },
sub options {
return {
zone => { optional => 0},
- tag => { optional => 0},
+ tag => { optional => 1},
alias => { optional => 1 },
ipv4 => { optional => 1 },
ipv6 => { optional => 1 },
next if $id eq $vnetid;
my $vnet = $vnet_cfg->{ids}->{$id};
if ($vnet->{type} eq 'vnet' && defined($vnet->{tag})) {
- die "tag $tag already exist in vnet $id" if $tag eq $vnet->{tag};
+ raise_param_exc({ tag => "tag $tag already exist in vnet $id"}) if $tag eq $vnet->{tag};
}
}
}
}
}
+sub verify_tag {
+ my ($class, $tag) = @_;
+
+ raise_param_exc({ tag => "missing vxlan tag"}) if !defined($tag);
+ raise_param_exc({ tag => "vxlan tag max value is 16777216"}) if $tag > 16777216;
+}
+
1;
# do nothing by default
}
+sub verify_tag {
+ my ($class, $tag) = @_;
+ # do nothing by default
+}
+
#helpers
sub parse_tag_number_or_range {
my ($str, $max, $tag) = @_;
use strict;
use warnings;
use PVE::Network::SDN::Zones::Plugin;
+use PVE::Exception qw(raise raise_param_exc);
use base('PVE::Network::SDN::Zones::Plugin');
return $err_msg;
}
+sub verify_tag {
+ my ($class, $tag) = @_;
+
+ raise_param_exc({ tag => "missing vlan tag"}) if !defined($tag);
+ raise_param_exc({ tag => "vlan tag max value is 4096"}) if $tag > 4096;
+}
+
1;
use strict;
use warnings;
use PVE::Network::SDN::Zones::Plugin;
+use PVE::Exception qw(raise raise_param_exc);
use base('PVE::Network::SDN::Zones::Plugin');
return $err_msg;
}
+sub verify_tag {
+ my ($class, $tag) = @_;
+
+ raise_param_exc({ tag => "vlan tag is not allowed on simple bridge"}) if defined($tag);
+}
+
1;
use strict;
use warnings;
use PVE::Network::SDN::Zones::Plugin;
+use PVE::Exception qw(raise raise_param_exc);
use base('PVE::Network::SDN::Zones::Plugin');
return $err_msg;
}
+sub verify_tag {
+ my ($class, $tag) = @_;
+
+ raise_param_exc({ tag => "missing vlan tag"}) if !defined($tag);
+ raise_param_exc({ tag => "vlan tag max value is 4096"}) if $tag > 4096;
+}
+
1;
use PVE::Tools qw($IPV4RE);
use PVE::INotify;
use PVE::Network::SDN::Controllers::EvpnPlugin;
+use PVE::Exception qw(raise raise_param_exc);
use base('PVE::Network::SDN::Zones::Plugin');
return $config;
}
+sub verify_tag {
+ my ($class, $tag) = @_;
+
+ raise_param_exc({ tag => "missing vxlan tag"}) if !defined($tag);
+ raise_param_exc({ tag => "vxlan tag max value is 16777216"}) if $tag > 16777216;
+}
+
1;