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