]>
Commit | Line | Data |
---|---|---|
ad03c543 AD |
1 | package PVE::Network::SDN::OVSFaucetPlugin; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use PVE::Network::SDN::VlanPlugin; | |
6 | ||
7 | use base('PVE::Network::SDN::VlanPlugin'); | |
8 | ||
9 | sub type { | |
10 | return 'ovsfaucet'; | |
11 | } | |
12 | ||
13 | sub plugindata { | |
14 | return { | |
15 | role => 'transport', | |
16 | }; | |
17 | } | |
18 | ||
19 | sub properties { | |
20 | return { | |
21 | 'dp-id' => { | |
22 | type => 'integer', | |
23 | description => 'Faucet dataplane id', | |
24 | }, | |
25 | }; | |
26 | } | |
27 | ||
28 | sub options { | |
29 | ||
30 | return { | |
31 | 'dp-id' => { optional => 0 }, | |
32 | 'uplink-id' => { optional => 0 }, | |
33 | 'controller' => { optional => 0 }, | |
34 | 'vlan-allowed' => { optional => 1 }, | |
35 | }; | |
36 | } | |
37 | ||
38 | # Plugin implementation | |
39 | sub generate_sdn_config { | |
40 | my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $config) = @_; | |
41 | ||
42 | my $mtu = $vnet->{mtu}; | |
43 | my $uplink = $plugin_config->{'uplink-id'}; | |
44 | my $dpid = $plugin_config->{'dp-id'}; | |
45 | my $dphex = printf("%x",$dpid); #fixme :should be 16characters hex | |
46 | ||
47 | my $iface = $uplinks->{$uplink}->{name}; | |
48 | $iface = "uplink${uplink}" if !$iface; | |
49 | ||
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}; | |
56 | ||
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; | |
62 | ||
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"; | |
67 | ||
68 | push(@{$config->{$zoneid}}, @iface_config) if !$config->{$zoneid}; | |
69 | ||
70 | return $config; | |
71 | } | |
72 | ||
73 | ||
74 | 1; | |
75 | ||
76 |