]> git.proxmox.com Git - pve-network.git/blame - PVE/Network/SDN/Zones/SimplePlugin.pm
polugin simple: whitespace/cleanups
[pve-network.git] / PVE / Network / SDN / Zones / SimplePlugin.pm
CommitLineData
880ae857
AD
1package PVE::Network::SDN::Zones::SimplePlugin;
2
3use strict;
4use warnings;
5use PVE::Network::SDN::Zones::Plugin;
1d44ce70 6use PVE::Exception qw(raise raise_param_exc);
880ae857
AD
7
8use base('PVE::Network::SDN::Zones::Plugin');
9
10sub type {
11 return 'simple';
12}
13
14sub options {
880ae857 15 return {
efe1459b 16 nodes => { optional => 1},
880ae857
AD
17 mtu => { optional => 1 }
18 };
19}
20
21# Plugin implementation
22sub generate_sdn_config {
23 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $interfaces_config, $config) = @_;
24
efe1459b
TL
25 return $config if$config->{$vnetid}; # nothing to do
26
880ae857
AD
27 my $ipv4 = $vnet->{ipv4};
28 my $ipv6 = $vnet->{ipv6};
29 my $mac = $vnet->{mac};
30 my $alias = $vnet->{alias};
31 my $mtu = $plugin_config->{mtu} if $plugin_config->{mtu};
32
efe1459b 33 # vnet bridge
880ae857
AD
34 my @iface_config = ();
35 push @iface_config, "address $ipv4" if $ipv4;
36 push @iface_config, "address $ipv6" if $ipv6;
37 push @iface_config, "hwaddress $mac" if $mac;
38 push @iface_config, "bridge_ports none";
39 push @iface_config, "bridge_stp off";
40 push @iface_config, "bridge_fd 0";
efe1459b 41 if ($vnet->{vlanaware}) {
880ae857
AD
42 push @iface_config, "bridge-vlan-aware yes";
43 push @iface_config, "bridge-vids 2-4094";
44 }
45 push @iface_config, "mtu $mtu" if $mtu;
46 push @iface_config, "alias $alias" if $alias;
efe1459b
TL
47
48 push @{$config->{$vnetid}}, @iface_config;
880ae857
AD
49
50 return $config;
51}
52
53sub status {
54 my ($class, $plugin_config, $zone, $vnetid, $vnet, $status) = @_;
55
880ae857 56 # ifaces to check
efe1459b
TL
57 my $ifaces = [ $vnetid ];
58 my $err_msg = [];
880ae857
AD
59 foreach my $iface (@{$ifaces}) {
60 if (!$status->{$iface}->{status}) {
61 push @$err_msg, "missing $iface";
efe1459b 62 } elsif ($status->{$iface}->{status} ne 'pass') {
880ae857
AD
63 push @$err_msg, "error iface $iface";
64 }
65 }
66 return $err_msg;
67}
68
1d44ce70
AD
69sub verify_tag {
70 my ($class, $tag) = @_;
71
72 raise_param_exc({ tag => "vlan tag is not allowed on simple bridge"}) if defined($tag);
73}
74
880ae857
AD
751;
76
77