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