avoid dependency problems
authorDietmar Maurer <dietmar@proxmox.com>
Mon, 17 Mar 2014 09:55:22 +0000 (10:55 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 17 Mar 2014 09:55:22 +0000 (10:55 +0100)
debian/control
src/PVE/Firewall.pm

index 42e3f7b..c31a1a1 100644 (file)
@@ -8,6 +8,6 @@ Standards-Version: 3.8.4
 Package: pve-firewall
 Architecture: any
 Conflicts: ulogd
-Depends: ${shlibs:Depends}, ${perl:Depends}, ${misc:Depends}, libpve-common-perl, qemu-server
+Depends: ${shlibs:Depends}, ${perl:Depends}, ${misc:Depends}, libpve-common-perl, pve-cluster, libpve-access-control
 Description: Proxmox VE Firewall
  This package contains the Proxmox VE Firewall.
index 0f2bc11..fa25815 100644 (file)
@@ -8,14 +8,26 @@ use PVE::INotify;
 use PVE::Cluster;
 use PVE::ProcFSTools;
 use PVE::Tools;
-use PVE::QemuServer;
-use PVE::OpenVZ; # dependeny problem?!
 use File::Basename;
 use File::Path;
 use IO::File;
 use Net::IP;
 use PVE::Tools qw(run_command lock_file);
 
+# dynamically include PVE::QemuServer and PVE::OpenVZ 
+# to avoid dependency problems
+my $have_qemu_server;
+eval {
+    require PVE::QemuServer;
+    $have_qemu_server = 1;
+};
+
+my $have_pve_manager;
+eval {
+    require PVE::OpenVZ;
+    $have_pve_manager = 1;
+};
+
 use Data::Dumper;
 
 # fixme: remove loglevel settings? NFLOG does not have --loglevel
@@ -1527,18 +1539,22 @@ sub read_local_vm_config {
        next if !$d->{node} || $d->{node} ne $nodename;
        next if !$d->{type};
        if ($d->{type} eq 'openvz') {
-           my $cfspath = PVE::OpenVZ::cfs_config_path($vmid);
-           if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) {
-               $openvz->{$vmid} = $conf;
+           if ($have_pve_manager) {
+               my $cfspath = PVE::OpenVZ::cfs_config_path($vmid);
+               if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) {
+                   $openvz->{$vmid} = $conf;
+               }
            }
        } elsif ($d->{type} eq 'qemu') {
-           my $cfspath = PVE::QemuServer::cfs_config_path($vmid);
-           if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) {
-               $qemu->{$vmid} = $conf;
+           if ($have_qemu_server) {
+               my $cfspath = PVE::QemuServer::cfs_config_path($vmid);
+               if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) {
+                   $qemu->{$vmid} = $conf;
+               }
            }
        }
     }
+
     return $vmdata;
 };