]> git.proxmox.com Git - pve-firewall.git/blobdiff - test/fwtester.pl
localnet: simplify code
[pve-firewall.git] / test / fwtester.pl
index 4d98c55d9750a2fffcb43accddd239b61e8e5516..e9ed6d16bd2ade8c79168b58246181339becc37d 100755 (executable)
@@ -5,6 +5,8 @@ use strict;
 use warnings;
 use Data::Dumper;
 use PVE::FirewallSimulator;
+use PVE::INotify;
+use PVE::Corosync;
 use Getopt::Long;
 use File::Basename;
 use Net::IP;
@@ -19,6 +21,13 @@ if (!GetOptions ('debug' => \$debug)) {
     print_usage_and_exit();
 }
 
+# load dummy corosync config to have fw create according rules
+my $corosync_conf_fn = "corosync.conf";
+my $raw = PVE::Tools::file_get_contents($corosync_conf_fn);
+my $local_hostname = PVE::INotify::nodename();
+(my $raw_replaced = $raw) =~ s/proxself$/$local_hostname\n/gm;
+my $corosync_conf = PVE::Corosync::parse_conf($corosync_conf_fn, $raw_replaced);
+
 PVE::FirewallSimulator::debug($debug);
  
 my $testfilename = shift;
@@ -37,7 +46,7 @@ sub run_tests {
     PVE::Firewall::local_network('172.16.1.0/24');
 
     my ($ruleset, $ipset_ruleset) = 
-       PVE::Firewall::compile(undef, undef, $vmdata);
+       PVE::Firewall::compile(undef, undef, $vmdata, $corosync_conf);
 
     my $filename = "$testdir/$testfile";
     my $fh = IO::File->new($filename) ||
@@ -107,6 +116,8 @@ my $vmdata = {
     qemu => {
        100 => {
            net0 => "e1000=0E:0B:38:B8:B3:21,bridge=vmbr0,firewall=1",
+           net1 => "e1000=0E:0B:38:B9:B4:21,bridge=vmbr1,firewall=1",
+           net2 => "e1000=0E:0B:38:BA:B4:21,bridge=vmbr2,firewall=1",
        },
        101 => {
            net0 => "e1000=0E:0B:38:B8:B3:22,bridge=vmbr0,firewall=1",
@@ -116,12 +127,12 @@ my $vmdata = {
            net0 => "e1000=0E:0B:38:B8:B4:21,bridge=vmbr1,firewall=1",
        },
     },
-    openvz => {
+    lxc => {
        200 => {
-           ip_address => { value => '10.0.200.1' },
+           net0 => "name=eth0,hwaddr=0E:18:24:41:2C:43,bridge=vmbr0,firewall=1,ip=10.0.200.1/24",
        },
        201 => {
-           ip_address => { value => '10.0.200.2' },
+           net0 => "name=eth0,hwaddr=0E:18:24:41:2C:44,bridge=vmbr0,firewall=1,ip=10.0.200.2/24",
        },
     },
 };