12 use PVE
::Network
::SDN
;
13 use PVE
::Network
::SDN
::Zones
;
14 use PVE
::Network
::SDN
::Controllers
;
20 # Read structure back in again
21 open my $in, '<', $file or die $!;
24 local $/; # slurp mode
25 $sdn_config = eval <$in>;
33 my @tests = grep { -d
} glob './zones/*/*';
35 foreach my $test (@tests) {
37 my $sdn_config = read_sdn_config
("./$test/sdn_config");
39 open my $fh1, '<', "./$test/interfaces" or die "can't read interfaces file";
40 my $interfaces_config = PVE
::INotify
::__read_etc_network_interfaces
($fh1, undef, undef);
43 my $pve_common_inotify;
44 $pve_common_inotify = Test
::MockModule-
>new('PVE::INotify');
45 $pve_common_inotify->mock(
50 return $interfaces_config;
55 $pve_sdn_subnets = Test
::MockModule-
>new('PVE::Network::SDN::Subnets');
56 $pve_sdn_subnets->mock(
58 return $sdn_config->{subnets
};
62 my $pve_sdn_zones_plugin;
63 $pve_sdn_zones_plugin = Test
::MockModule-
>new('PVE::Network::SDN::Zones::Plugin');
64 $pve_sdn_zones_plugin->mock(
65 get_local_route_ip
=> sub {
66 my $outiface = "vmbr0";
67 my $outip = $interfaces_config->{ifaces
}->{$outiface}->{address
};
68 return ($outip, $outiface);
71 return $interfaces_config->{ifaces
}->{vmbr0
}->{'bridge_vlan_aware'};
74 return 1 if $interfaces_config->{ifaces
}->{vmbr0
}->{'type'} eq 'OVSBridge';
76 get_bridge_ifaces
=> sub {
84 my $sdn_module = Test
::MockModule-
>new("PVE::Network::SDN");
92 my $expected = read_file
("./$test/expected_sdn_interfaces");
96 $result = PVE
::Network
::SDN
::Zones
::generate_etc_network_config
();
102 is ($result, $expected, $name);
105 if ($sdn_config->{controllers
}) {
106 my $expected = read_file
("./$test/expected_controller_config");
107 my $controller_rawconfig = "";
110 my $config = PVE
::Network
::SDN
::Controllers
::generate_controller_config
();
111 $controller_rawconfig = PVE
::Network
::SDN
::Controllers
::generate_controller_rawconfig
($config);
117 is ($controller_rawconfig, $expected, $name);