1 package PVE
::Network
::SDN
::FaucetControllerPlugin
;
5 use PVE
::Network
::SDN
::Plugin
;
8 use PVE
::JSONSchema
qw(get_standard_option);
12 use base
('PVE::Network::SDN::Plugin');
15 return 'faucetcontroller';
29 # Plugin implementation
30 sub generate_controller_config
{
31 my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
35 sub generate_controller_transport_config
{
36 my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
38 my $dpid = $plugin_config->{'dp-id'};
39 my $dphex = printf("%x",$dpid);
41 my $transport_config = {
43 hardware
=> "Open vSwitch",
46 $config->{faucet
}->{dps
}->{$id} = $transport_config;
51 sub generate_controller_vnet_config
{
52 my ($class, $plugin_config, $controller, $transportid, $vnetid, $config) = @_;
54 my $mac = $plugin_config->{mac
};
55 my $ipv4 = $plugin_config->{ipv4
};
56 my $ipv6 = $plugin_config->{ipv6
};
57 my $tag = $plugin_config->{tag
};
58 my $alias = $plugin_config->{alias
};
61 push @ips, $ipv4 if $ipv4;
62 push @ips, $ipv6 if $ipv6;
64 my $vlan_config = { vid
=> $tag };
66 $vlan_config->{description
} = $alias if $alias;
67 $vlan_config->{faucet_mac
} = $mac if $mac;
68 $vlan_config->{faucet_vips
} = \
@ips if scalar @ips > 0;
70 $config->{faucet
}->{vlans
}->{$vnetid} = $vlan_config;
72 push(@{$config->{faucet
}->{routers
}->{$transportid}->{vlans
}} , $vnetid);
77 my ($class, $routerid, $sdn_cfg) = @_;
82 my ($class, $routerid, $sdn_cfg) = @_;
86 sub write_controller_config
{
87 my ($class, $plugin_config, $config) = @_;
89 my $rawconfig = encode
('UTF-8', CPAN
::Meta
::YAML
::Dump
($config->{faucet
}));
91 return if !$rawconfig;
92 return if !-d
"/etc/faucet";
94 my $frr_config_file = "/etc/faucet/faucet.yaml";
96 my $writefh = IO
::File-
>new($frr_config_file,">");
97 print $writefh $rawconfig;
101 sub reload_controller
{
104 my $conf_file = "/etc/faucet/faucet.yaml";
105 my $bin_path = "/usr/bin/faucet";
107 if (-e
$conf_file && -e
$bin_path) {
108 PVE
::Tools
::run_command
(['systemctl', 'reload', 'faucet']);