start example code
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 3 Aug 2012 09:19:45 +0000 (11:19 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 3 Aug 2012 09:19:45 +0000 (11:19 +0200)
PVE/Firewall.pm [new file with mode: 0644]
PVE/Firewall.pm~ [new file with mode: 0644]
fwtest.pl [new file with mode: 0755]

diff --git a/PVE/Firewall.pm b/PVE/Firewall.pm
new file mode 100644 (file)
index 0000000..f75879e
--- /dev/null
@@ -0,0 +1,37 @@
+package PVE::Firewall;
+
+use warnings;
+use strict;
+use Data::Dumper;
+
+use PVE::QemuServer;
+
+# we need complete VM configuration of all VMs (openvz/qemu)
+# in vmdata
+
+sub compile {
+    my ($vmdata) = @_;
+
+    my $netinfo;
+
+    foreach my $vmid (keys %{$vmdata->{qemu}}) {
+       $netinfo->{$vmid} = {};
+       my $conf = $vmdata->{qemu}->{$vmid};
+       foreach my $opt (keys %$conf) {
+           next if $opt !~ m/^net(\d+)$/;
+           my $net = PVE::QemuServer::parse_net($conf->{$opt});
+           next if !$net;
+           $netinfo->{$vmid} = $net;
+       }
+    }
+
+    print Dumper($netinfo);
+
+}
+
+sub activate {
+
+}
+
+
+1;
diff --git a/PVE/Firewall.pm~ b/PVE/Firewall.pm~
new file mode 100644 (file)
index 0000000..6ca8749
--- /dev/null
@@ -0,0 +1,20 @@
+package PVE::Firewall;
+
+use warnings;
+use strict;
+
+# we need complete VM configuration of all VMs (openvz/qemu)
+# in vmdata
+
+sub compile {
+    my ($vmdata} = @_;
+
+
+}
+
+sub activate {
+
+}
+
+
+1;
diff --git a/fwtest.pl b/fwtest.pl
new file mode 100755 (executable)
index 0000000..4e3a637
--- /dev/null
+++ b/fwtest.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl -w
+
+use strict;
+use lib qw(.);
+use PVE::Firewall;
+
+my $vmdata = {
+    qemu => {
+       100 => {
+           net0 => 'rtl8139=9A:42:2D:0C:01:FF,bridge=vmbr0',
+       },
+       101 => {
+           net0 => 'rtl8139=0E:9D:ED:CC:9B:ED,bridge=vmbr0',
+       },
+    },
+};
+
+PVE::Firewall::compile($vmdata);
+
+exit(0);