]> git.proxmox.com Git - pve-network.git/blob - PVE/Network/SDN/Zones/FaucetPlugin.pm
move dns options from subnets to zone
[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 };
33 }
34
35 # Plugin implementation
36 sub generate_sdn_config {
37 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $controller, $config) = @_;
38
39 my $mtu = $vnet->{mtu};
40 my $uplink = $plugin_config->{'uplink-id'};
41 my $dpid = $plugin_config->{'dp-id'};
42 my $dphex = printf("%x",$dpid); #fixme :should be 16characters hex
43
44 my $iface = $uplinks->{$uplink}->{name};
45 $iface = "uplink${uplink}" if !$iface;
46
47 #tagged interface
48 my @iface_config = ();
49 push @iface_config, "ovs_type OVSPort";
50 push @iface_config, "ovs_bridge $zoneid";
51 push @iface_config, "ovs_mtu $mtu" if $mtu;
52 push(@{$config->{$iface}}, @iface_config) if !$config->{$iface};
53
54 #vnet bridge
55 @iface_config = ();
56 push @iface_config, "ovs_port $iface";
57 push @iface_config, "ovs_type OVSBridge";
58 push @iface_config, "ovs_mtu $mtu" if $mtu;
59
60 push @iface_config, "ovs_extra set bridge $zoneid other-config:datapath-id=$dphex";
61 push @iface_config, "ovs_extra set bridge $zoneid other-config:disable-in-band=true";
62 push @iface_config, "ovs_extra set bridge $zoneid fail_mode=secure";
63 push @iface_config, "ovs_extra set-controller $vnetid tcp:127.0.0.1:6653";
64
65 push(@{$config->{$zoneid}}, @iface_config) if !$config->{$zoneid};
66
67 return $config;
68 }
69
70
71 1;
72
73