[pve-devel] [PATCH pve-network 1/3] vlan, vxlan plugin : add on_delete_hook
Alexandre Derumier
aderumier at odiso.com
Mon May 6 14:47:12 CEST 2019
verify that a vnet is not using this transport
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/API2/Network/Network.pm | 2 +-
PVE/Network/Network/VlanPlugin.pm | 9 +++++++--
PVE/Network/Network/VnetPlugin.pm | 2 +-
PVE/Network/Network/VxlanMulticastPlugin.pm | 7 ++++++-
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/PVE/API2/Network/Network.pm b/PVE/API2/Network/Network.pm
index 3dd0a57..524c6c3 100644
--- a/PVE/API2/Network/Network.pm
+++ b/PVE/API2/Network/Network.pm
@@ -234,7 +234,7 @@ __PACKAGE__->register_method ({
my $scfg = PVE::Network::Network::network_config($cfg, $networkid);
my $plugin = PVE::Network::Network::Plugin->lookup($scfg->{type});
- $plugin->on_delete_hook($networkid, $scfg);
+ $plugin->on_delete_hook($networkid, $cfg);
delete $cfg->{ids}->{$networkid};
PVE::Network::Network::write_config($cfg);
diff --git a/PVE/Network/Network/VlanPlugin.pm b/PVE/Network/Network/VlanPlugin.pm
index 4f553ab..affa274 100644
--- a/PVE/Network/Network/VlanPlugin.pm
+++ b/PVE/Network/Network/VlanPlugin.pm
@@ -99,9 +99,14 @@ sub generate_network_config {
}
sub on_delete_hook {
- my ($class, $networkid, $scfg) = @_;
+ my ($class, $transportid, $network_cfg) = @_;
- # verify that no vnet are associated to this transport
+ # verify that no vnet are associated to this transport
+ foreach my $id (keys %{$network_cfg->{ids}}) {
+ my $network = $network_cfg->{ids}->{$id};
+ die "transport $transportid is used by vnet $id"
+ if ($network->{type} eq 'vnet' && defined($network->{transportzone}) && $network->{transportzone} eq $transportid);
+ }
}
sub on_update_hook {
diff --git a/PVE/Network/Network/VnetPlugin.pm b/PVE/Network/Network/VnetPlugin.pm
index 593e475..b255691 100644
--- a/PVE/Network/Network/VnetPlugin.pm
+++ b/PVE/Network/Network/VnetPlugin.pm
@@ -81,7 +81,7 @@ sub options {
}
sub on_delete_hook {
- my ($class, $networkid, $scfg) = @_;
+ my ($class, $networkid, $network_cfg) = @_;
# verify than no vm or ct have interfaces in this bridge
my $vmdata = read_cluster_vm_config();
diff --git a/PVE/Network/Network/VxlanMulticastPlugin.pm b/PVE/Network/Network/VxlanMulticastPlugin.pm
index d6cc4f6..f71094a 100644
--- a/PVE/Network/Network/VxlanMulticastPlugin.pm
+++ b/PVE/Network/Network/VxlanMulticastPlugin.pm
@@ -84,9 +84,14 @@ sub generate_network_config {
}
sub on_delete_hook {
- my ($class, $networkid, $scfg) = @_;
+ my ($class, $transportid, $network_cfg) = @_;
# verify that no vnet are associated to this transport
+ foreach my $id (keys %{$network_cfg->{ids}}) {
+ my $network = $network_cfg->{ids}->{$id};
+ die "transport $transportid is used by vnet $id"
+ if ($network->{type} eq 'vnet' && defined($network->{transportzone}) && $network->{transportzone} eq $transportid);
+ }
}
sub on_update_hook {
--
2.11.0
More information about the pve-devel
mailing list