]> git.proxmox.com Git - pve-network.git/blob - PVE/Network/SDN/Zones/FaucetPlugin.pm
zones: code/indendation cleanup
[pve-network.git] / PVE / Network / SDN / Zones / FaucetPlugin.pm
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 dns => { optional => 1 },
30 reversedns => { optional => 1 },
31 dnszone => { optional => 1 },
32 ipam => { optional => 0 },
33 };
34 }
35
36 # Plugin implementation
37 sub generate_sdn_config {
38 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $controller, $config) = @_;
39
40 my $mtu = $vnet->{mtu};
41 my $uplink = $plugin_config->{'uplink-id'};
42 my $dpid = $plugin_config->{'dp-id'};
43 my $dphex = printf("%x",$dpid); #fixme :should be 16characters hex
44
45 my $iface = $uplinks->{$uplink}->{name};
46 $iface = "uplink${uplink}" if !$iface;
47
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};
54
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;
60
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";
65
66 push(@{$config->{$zoneid}}, @iface_config) if !$config->{$zoneid};
67
68 return $config;
69 }
70
71
72 1;
73
74