From: Alexandre Derumier Date: Fri, 7 Jun 2019 04:52:12 +0000 (+0200) Subject: remove vnet bridge delete hook X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=cf5816ef42af03a467b89894ee49aec985abdd37;p=matthieu%2Fpve-network.git remove vnet bridge delete hook We can check that in local reload when we'll generate config Signed-off-by: Alexandre Derumier --- diff --git a/PVE/Network/Network/VnetPlugin.pm b/PVE/Network/Network/VnetPlugin.pm index b255691..eeb7e82 100644 --- a/PVE/Network/Network/VnetPlugin.pm +++ b/PVE/Network/Network/VnetPlugin.pm @@ -8,29 +8,10 @@ use base('PVE::Network::Network::Plugin'); use PVE::Cluster; -# dynamically include PVE::QemuServer and PVE::LXC -# to avoid dependency problems -my $have_qemu_server; -eval { - require PVE::QemuServer; - require PVE::QemuConfig; - $have_qemu_server = 1; -}; - -my $have_lxc; -eval { - require PVE::LXC; - require PVE::LXC::Config; - - $have_lxc = 1; -}; - sub type { return 'vnet'; } - - sub properties { return { transportzone => { @@ -83,27 +64,7 @@ sub options { sub on_delete_hook { my ($class, $networkid, $network_cfg) = @_; - # verify than no vm or ct have interfaces in this bridge - my $vmdata = read_cluster_vm_config(); - - foreach my $vmid (sort keys %{$vmdata->{qemu}}) { - my $conf = $vmdata->{qemu}->{$vmid}; - foreach my $netid (sort keys %$conf) { - next if $netid !~ m/^net(\d+)$/; - my $net = PVE::QemuServer::parse_net($conf->{$netid}); - die "vnet $networkid is used by vm $vmid" if $net->{bridge} eq $networkid; - } - } - - foreach my $vmid (sort keys %{$vmdata->{lxc}}) { - my $conf = $vmdata->{lxc}->{$vmid}; - foreach my $netid (sort keys %$conf) { - next if $netid !~ m/^net(\d+)$/; - my $net = PVE::LXC::Config->parse_lxc_network($conf->{$netid}); - die "vnet $networkid is used by ct $vmid" if $net->{bridge} eq $networkid; - } - } - + return; } sub on_update_hook { @@ -121,35 +82,4 @@ sub on_update_hook { } } -sub read_cluster_vm_config { - - my $qemu = {}; - my $lxc = {}; - - my $vmdata = { qemu => $qemu, lxc => $lxc }; - - my $vmlist = PVE::Cluster::get_vmlist(); - return $vmdata if !$vmlist || !$vmlist->{ids}; - my $ids = $vmlist->{ids}; - - foreach my $vmid (keys %$ids) { - next if !$vmid; - my $d = $ids->{$vmid}; - next if !$d->{type}; - if ($d->{type} eq 'qemu' && $have_qemu_server) { - my $cfspath = PVE::QemuConfig->cfs_config_path($vmid); - if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) { - $qemu->{$vmid} = $conf; - } - } elsif ($d->{type} eq 'lxc' && $have_lxc) { - my $cfspath = PVE::LXC::Config->cfs_config_path($vmid); - if (my $conf = PVE::Cluster::cfs_read_file($cfspath)) { - $lxc->{$vmid} = $conf; - } - } - } - - return $vmdata; -}; - 1;