minimum => 1, maximum => 4096,
description => 'Uplink interface',
},
- 'vlan-allowed' => {
- type => 'string', format => 'pve-sdn-vlanrange',
- description => "Allowed vlan range",
- },
};
}
sub options {
return {
+ nodes => { optional => 1},
'uplink-id' => { optional => 0 },
- 'vlan-allowed' => { optional => 1 },
};
}
# Plugin implementation
sub generate_sdn_config {
- my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $config) = @_;
+ my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $controller, $config) = @_;
my $tag = $vnet->{tag};
my $mtu = $vnet->{mtu};
return $config;
}
-sub on_delete_hook {
- my ($class, $transportid, $sdn_cfg) = @_;
-
- # verify that no vnet are associated to this transport
- foreach my $id (keys %{$sdn_cfg->{ids}}) {
- my $sdn = $sdn_cfg->{ids}->{$id};
- die "transport $transportid is used by vnet $id"
- if ($sdn->{type} eq 'vnet' && defined($sdn->{zone}) && $sdn->{zone} eq $transportid);
- }
-}
-
-sub on_update_hook {
- my ($class, $transportid, $sdn_cfg) = @_;
-
- my $transport = $sdn_cfg->{ids}->{$transportid};
-
- # verify that vlan-allowed don't conflict with another vlan-allowed transport
-
- # verify that vlan-allowed is matching currently vnet tag in this transport
- my $vlanallowed = $transport->{'vlan-allowed'};
- if ($vlanallowed) {
- foreach my $id (keys %{$sdn_cfg->{ids}}) {
- my $sdn = $sdn_cfg->{ids}->{$id};
- if ($sdn->{type} eq 'vnet' && defined($sdn->{tag})) {
- if(defined($sdn->{zone}) && $sdn->{zone} eq $transportid) {
- my $tag = $sdn->{tag};
- eval {
- PVE::Network::SDN::Zones::Plugin::parse_tag_number_or_range($vlanallowed, '4096', $tag);
- };
- if($@) {
- die "vlan $tag is not allowed in transport $transportid";
- }
- }
- }
- }
- }
-}
-
1;