]>
Commit | Line | Data |
---|---|---|
ad03c543 AD |
1 | package PVE::Network::SDN::FaucetPlugin; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
0193ebe5 | 5 | use PVE::Network::SDN::VlanPlugin; |
ad03c543 | 6 | |
0193ebe5 | 7 | use base('PVE::Network::SDN::VlanPlugin'); |
ad03c543 AD |
8 | |
9 | sub type { | |
10 | return 'faucet'; | |
11 | } | |
12 | ||
13 | sub plugindata { | |
14 | return { | |
0193ebe5 | 15 | role => 'transport', |
ad03c543 AD |
16 | }; |
17 | } | |
18 | ||
19 | sub properties { | |
20 | return { | |
0193ebe5 AD |
21 | 'dp-id' => { |
22 | type => 'integer', | |
23 | description => 'Faucet dataplane id', | |
24 | }, | |
ad03c543 AD |
25 | }; |
26 | } | |
27 | ||
0193ebe5 | 28 | sub options { |
ad03c543 | 29 | |
0193ebe5 AD |
30 | return { |
31 | 'dp-id' => { optional => 0 }, | |
32 | 'uplink-id' => { optional => 0 }, | |
33 | 'controller' => { optional => 0 }, | |
34 | 'vlan-allowed' => { optional => 1 }, | |
35 | }; | |
ad03c543 AD |
36 | } |
37 | ||
0193ebe5 AD |
38 | # Plugin implementation |
39 | sub generate_sdn_config { | |
40 | my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $config) = @_; | |
ad03c543 | 41 | |
0193ebe5 AD |
42 | my $mtu = $vnet->{mtu}; |
43 | my $uplink = $plugin_config->{'uplink-id'}; | |
ad03c543 | 44 | my $dpid = $plugin_config->{'dp-id'}; |
0193ebe5 | 45 | my $dphex = printf("%x",$dpid); #fixme :should be 16characters hex |
ad03c543 | 46 | |
0193ebe5 AD |
47 | my $iface = $uplinks->{$uplink}->{name}; |
48 | $iface = "uplink${uplink}" if !$iface; | |
ad03c543 | 49 | |
0193ebe5 AD |
50 | #tagged interface |
51 | my @iface_config = (); | |
52 | push @iface_config, "ovs_type OVSPort"; | |
53 | push @iface_config, "ovs_bridge $zoneid"; | |
54 | push @iface_config, "ovs_mtu $mtu" if $mtu; | |
55 | push(@{$config->{$iface}}, @iface_config) if !$config->{$iface}; | |
ad03c543 | 56 | |
0193ebe5 AD |
57 | #vnet bridge |
58 | @iface_config = (); | |
59 | push @iface_config, "ovs_port $iface"; | |
60 | push @iface_config, "ovs_type OVSBridge"; | |
61 | push @iface_config, "ovs_mtu $mtu" if $mtu; | |
ad03c543 | 62 | |
0193ebe5 AD |
63 | push @iface_config, "ovs_extra set bridge $zoneid other-config:datapath-id=$dphex"; |
64 | push @iface_config, "ovs_extra set bridge $zoneid other-config:disable-in-band=true"; | |
65 | push @iface_config, "ovs_extra set bridge $zoneid fail_mode=secure"; | |
66 | push @iface_config, "ovs_extra set-controller $vnetid tcp:127.0.0.1:6653"; | |
ad03c543 | 67 | |
0193ebe5 | 68 | push(@{$config->{$zoneid}}, @iface_config) if !$config->{$zoneid}; |
ad03c543 | 69 | |
0193ebe5 | 70 | return $config; |
ad03c543 AD |
71 | } |
72 | ||
fa609bdd | 73 | |
ad03c543 AD |
74 | 1; |
75 | ||
0193ebe5 | 76 |