allow to create standalone or simple routed vnets Signed-off-by: Alexandre Derumier <aderum...@odiso.com> --- PVE/API2/Network/SDN/Zones.pm | 1 + PVE/Network/SDN/Zones.pm | 2 + PVE/Network/SDN/Zones/Makefile | 2 +- PVE/Network/SDN/Zones/SimplePlugin.pm | 70 +++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 PVE/Network/SDN/Zones/SimplePlugin.pm
diff --git a/PVE/API2/Network/SDN/Zones.pm b/PVE/API2/Network/SDN/Zones.pm index 10ca616..3e371df 100644 --- a/PVE/API2/Network/SDN/Zones.pm +++ b/PVE/API2/Network/SDN/Zones.pm @@ -15,6 +15,7 @@ use PVE::Network::SDN::Zones::QinQPlugin; use PVE::Network::SDN::Zones::VxlanPlugin; use PVE::Network::SDN::Zones::EvpnPlugin; use PVE::Network::SDN::Zones::FaucetPlugin; +use PVE::Network::SDN::Zones::SimplePlugin; use Storable qw(dclone); use PVE::JSONSchema qw(get_standard_option); diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm index 3e03f11..b6c5c34 100644 --- a/PVE/Network/SDN/Zones.pm +++ b/PVE/Network/SDN/Zones.pm @@ -16,6 +16,7 @@ use PVE::Network::SDN::Zones::QinQPlugin; use PVE::Network::SDN::Zones::VxlanPlugin; use PVE::Network::SDN::Zones::EvpnPlugin; use PVE::Network::SDN::Zones::FaucetPlugin; +use PVE::Network::SDN::Zones::SimplePlugin; use PVE::Network::SDN::Zones::Plugin; PVE::Network::SDN::Zones::VlanPlugin->register(); @@ -23,6 +24,7 @@ PVE::Network::SDN::Zones::QinQPlugin->register(); PVE::Network::SDN::Zones::VxlanPlugin->register(); PVE::Network::SDN::Zones::EvpnPlugin->register(); PVE::Network::SDN::Zones::FaucetPlugin->register(); +PVE::Network::SDN::Zones::SimplePlugin->register(); PVE::Network::SDN::Zones::Plugin->init(); my $local_network_sdn_file = "/etc/network/interfaces.d/sdn"; diff --git a/PVE/Network/SDN/Zones/Makefile b/PVE/Network/SDN/Zones/Makefile index ba9a4b5..8454388 100644 --- a/PVE/Network/SDN/Zones/Makefile +++ b/PVE/Network/SDN/Zones/Makefile @@ -1,4 +1,4 @@ -SOURCES=Plugin.pm VlanPlugin.pm VxlanPlugin.pm FaucetPlugin.pm EvpnPlugin.pm QinQPlugin.pm +SOURCES=Plugin.pm VlanPlugin.pm VxlanPlugin.pm FaucetPlugin.pm EvpnPlugin.pm QinQPlugin.pm SimplePlugin.pm PERL5DIR=${DESTDIR}/usr/share/perl5 diff --git a/PVE/Network/SDN/Zones/SimplePlugin.pm b/PVE/Network/SDN/Zones/SimplePlugin.pm new file mode 100644 index 0000000..60fb7db --- /dev/null +++ b/PVE/Network/SDN/Zones/SimplePlugin.pm @@ -0,0 +1,70 @@ +package PVE::Network::SDN::Zones::SimplePlugin; + +use strict; +use warnings; +use PVE::Network::SDN::Zones::Plugin; + +use base('PVE::Network::SDN::Zones::Plugin'); + +sub type { + return 'simple'; +} + +sub options { + + return { + nodes => { optional => 1}, + mtu => { optional => 1 } + }; +} + +# Plugin implementation +sub generate_sdn_config { + my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $interfaces_config, $config) = @_; + + my $ipv4 = $vnet->{ipv4}; + my $ipv6 = $vnet->{ipv6}; + my $mac = $vnet->{mac}; + my $alias = $vnet->{alias}; + my $mtu = $plugin_config->{mtu} if $plugin_config->{mtu}; + + #vnet bridge + my @iface_config = (); + push @iface_config, "address $ipv4" if $ipv4; + push @iface_config, "address $ipv6" if $ipv6; + push @iface_config, "hwaddress $mac" if $mac; + push @iface_config, "bridge_ports none"; + push @iface_config, "bridge_stp off"; + push @iface_config, "bridge_fd 0"; + if($vnet->{vlanaware}) { + push @iface_config, "bridge-vlan-aware yes"; + push @iface_config, "bridge-vids 2-4094"; + } + push @iface_config, "mtu $mtu" if $mtu; + push @iface_config, "alias $alias" if $alias; + push(@{$config->{$vnetid}}, @iface_config) if !$config->{$vnetid}; + + return $config; +} + +sub status { + my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_; + + my $err_msg = []; + + # ifaces to check + my $ifaces = [ $vnetid]; + + foreach my $iface (@{$ifaces}) { + if (!$status->{$iface}->{status}) { + push @$err_msg, "missing $iface"; + } elsif ($status->{$iface}->{status} ne 'pass') { + push @$err_msg, "error iface $iface"; + } + } + return $err_msg; +} + +1; + + -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel