[pve-devel] [PATCH v2 pve-network 14/15] cleanup old transport/router/sdn_cfg references

Alexandre Derumier aderumier at odiso.com
Tue Nov 26 10:00:29 CET 2019


use zone/controller...

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Network/SDN/Controllers.pm         |  24 ++---
 PVE/API2/Network/SDN/Zones/Content.pm       |   6 +-
 PVE/API2/Network/SDN/Zones/Status.pm        |   6 +-
 PVE/Network/SDN.pm                          |   4 +-
 PVE/Network/SDN/Controllers.pm              |  22 ++---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm   | 100 ++++++++++----------
 PVE/Network/SDN/Controllers/FaucetPlugin.pm |  24 ++---
 PVE/Network/SDN/Controllers/Plugin.pm       |   8 +-
 PVE/Network/SDN/VnetPlugin.pm               |  18 ++--
 PVE/Network/SDN/Zones.pm                    |  26 ++---
 PVE/Network/SDN/Zones/Plugin.pm             |  13 ++-
 PVE/Network/SDN/Zones/QinQPlugin.pm         |   6 +-
 PVE/Network/SDN/Zones/VlanPlugin.pm         |  11 ---
 PVE/Network/SDN/Zones/VxlanPlugin.pm        |  11 ---
 14 files changed, 125 insertions(+), 154 deletions(-)

diff --git a/PVE/API2/Network/SDN/Controllers.pm b/PVE/API2/Network/SDN/Controllers.pm
index 70ecd60..03da2ad 100644
--- a/PVE/API2/Network/SDN/Controllers.pm
+++ b/PVE/API2/Network/SDN/Controllers.pm
@@ -135,17 +135,17 @@ __PACKAGE__->register_method ({
         PVE::Network::SDN::Controllers::lock_sdn_controllers_config(
 	    sub {
 
-		my $cfg = PVE::Network::SDN::Controllers::config();
+		my $controller_cfg = PVE::Network::SDN::Controllers::config();
 
 		my $scfg = undef;
-		if ($scfg = PVE::Network::SDN::Controllers::sdn_controllers_config($cfg, $id, 1)) {
+		if ($scfg = PVE::Network::SDN::Controllers::sdn_controllers_config($controller_cfg, $id, 1)) {
 		    die "sdn controller object ID '$id' already defined\n";
 		}
 
-		$cfg->{ids}->{$id} = $opts;
-		$plugin->on_update_hook($id, $cfg);
+		$controller_cfg->{ids}->{$id} = $opts;
+		$plugin->on_update_hook($id, $controller_cfg);
 
-		PVE::Network::SDN::Controllers::write_config($cfg);
+		PVE::Network::SDN::Controllers::write_config($controller_cfg);
 
 	    }, "create sdn controller object failed");
 
@@ -194,11 +194,11 @@ __PACKAGE__->register_method ({
         PVE::Network::SDN::Controllers::lock_sdn_controllers_config(
 	 sub {
 
-	    my $cfg = PVE::Network::SDN::Controllers::config();
+	    my $controller_cfg = PVE::Network::SDN::Controllers::config();
 
-	    PVE::SectionConfig::assert_if_modified($cfg, $digest);
+	    PVE::SectionConfig::assert_if_modified($controller_cfg, $digest);
 
-	    my $scfg = PVE::Network::SDN::Controllers::sdn_controllers_config($cfg, $id);
+	    my $scfg = PVE::Network::SDN::Controllers::sdn_controllers_config($controller_cfg, $id);
 
 	    my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($scfg->{type});
 	    my $opts = $plugin->check_config($id, $param, 0, 1);
@@ -207,9 +207,9 @@ __PACKAGE__->register_method ({
 		$scfg->{$k} = $opts->{$k};
 	    }
 
-	    $plugin->on_update_hook($id, $cfg);
+	    $plugin->on_update_hook($id, $controller_cfg);
 
-	    PVE::Network::SDN::Controllers::write_config($cfg);
+	    PVE::Network::SDN::Controllers::write_config($controller_cfg);
 
 	    }, "update sdn controller object failed");
 
@@ -248,9 +248,9 @@ __PACKAGE__->register_method ({
 
 		my $plugin = PVE::Network::SDN::Controllers::Plugin->lookup($scfg->{type});
 
-		my $transport_cfg = PVE::Network::SDN::Zones::config();
+		my $zone_cfg = PVE::Network::SDN::Zones::config();
 
-		$plugin->on_delete_hook($id, $transport_cfg);
+		$plugin->on_delete_hook($id, $zone_cfg);
 
 		delete $cfg->{ids}->{$id};
 		PVE::Network::SDN::Controllers::write_config($cfg);
diff --git a/PVE/API2/Network/SDN/Zones/Content.pm b/PVE/API2/Network/SDN/Zones/Content.pm
index f391201..cb738b5 100644
--- a/PVE/API2/Network/SDN/Zones/Content.pm
+++ b/PVE/API2/Network/SDN/Zones/Content.pm
@@ -65,14 +65,14 @@ __PACKAGE__->register_method ({
 
 	my $authuser = $rpcenv->get_user();
 
-	my $transportid = $param->{zone};
+	my $zoneid = $param->{zone};
 
 	my $res = [];
 
-        my ($transport_status, $vnet_status) = PVE::Network::SDN::status();
+        my ($zone_status, $vnet_status) = PVE::Network::SDN::status();
 
 	foreach my $id (keys %{$vnet_status}) {
-	    if ($vnet_status->{$id}->{zone} eq $transportid) {
+	    if ($vnet_status->{$id}->{zone} eq $zoneid) {
 		my $item->{vnet} = $id;
 		$item->{status} = $vnet_status->{$id}->{'status'};
 		$item->{status} = $vnet_status->{$id}->{'statusmsg'};
diff --git a/PVE/API2/Network/SDN/Zones/Status.pm b/PVE/API2/Network/SDN/Zones/Status.pm
index b543a17..abaa40d 100644
--- a/PVE/API2/Network/SDN/Zones/Status.pm
+++ b/PVE/API2/Network/SDN/Zones/Status.pm
@@ -62,11 +62,11 @@ __PACKAGE__->register_method ({
 
 	my $res = [];
 
-        my ($transport_status, $vnet_status) = PVE::Network::SDN::status();
+        my ($zone_status, $vnet_status) = PVE::Network::SDN::status();
 
-        foreach my $id (keys %{$transport_status}) {
+        foreach my $id (keys %{$zone_status}) {
 	    my $item->{zone} = $id;
-	    $item->{status} = $transport_status->{$id}->{'status'};
+	    $item->{status} = $zone_status->{$id}->{'status'};
 	    push @$res,$item;
         }
 
diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index 4088221..2e996e9 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -41,8 +41,8 @@ sub ifquery_check {
 
 sub status {
 
-    my ($transport_status, $vnet_status) = PVE::Network::SDN::Zones::status();
-    return($transport_status, $vnet_status);
+    my ($zone_status, $vnet_status) = PVE::Network::SDN::Zones::status();
+    return($zone_status, $vnet_status);
 }
 
 1;
diff --git a/PVE/Network/SDN/Controllers.pm b/PVE/Network/SDN/Controllers.pm
index f089538..773e145 100644
--- a/PVE/Network/SDN/Controllers.pm
+++ b/PVE/Network/SDN/Controllers.pm
@@ -69,9 +69,9 @@ sub complete_sdn_controller {
 sub generate_controller_config {
 
     my $vnet_cfg = PVE::Cluster::cfs_read_file('sdn/vnets.cfg');
-    my $transport_cfg = PVE::Cluster::cfs_read_file('sdn/zones.cfg');
+    my $zone_cfg = PVE::Cluster::cfs_read_file('sdn/zones.cfg');
     my $controller_cfg = PVE::Cluster::cfs_read_file('sdn/controllers.cfg');
-    return if !$vnet_cfg && !$transport_cfg && !$controller_cfg;
+    return if !$vnet_cfg && !$zone_cfg && !$controller_cfg;
 
     #read main config for physical interfaces
     my $current_config_file = "/etc/network/interfaces";
@@ -99,29 +99,29 @@ sub generate_controller_config {
 	$plugin->generate_controller_config($plugin_config, $plugin_config, $id, $uplinks, $config);
     }
 
-    foreach my $id (keys %{$transport_cfg->{ids}}) {
-	my $plugin_config = $transport_cfg->{ids}->{$id};
+    foreach my $id (keys %{$zone_cfg->{ids}}) {
+	my $plugin_config = $zone_cfg->{ids}->{$id};
 	my $controllerid = $plugin_config->{controller};
 	next if !$controllerid;
 	my $controller = $controller_cfg->{ids}->{$controllerid};
 	if ($controller) {
 	    my $controller_plugin = PVE::Network::SDN::Controllers::Plugin->lookup($controller->{type});
-	    $controller_plugin->generate_controller_transport_config($plugin_config, $controller, $id, $uplinks, $config);
+	    $controller_plugin->generate_controller_zone_config($plugin_config, $controller, $id, $uplinks, $config);
 	}
     }
 
     foreach my $id (keys %{$vnet_cfg->{ids}}) {
 	my $plugin_config = $vnet_cfg->{ids}->{$id};
-	my $transportid = $plugin_config->{zone};
-	next if !$transportid;
-	my $transport = $transport_cfg->{ids}->{$transportid};
-	next if !$transport;
-	my $controllerid = $transport->{controller};
+	my $zoneid = $plugin_config->{zone};
+	next if !$zoneid;
+	my $zone = $zone_cfg->{ids}->{$zoneid};
+	next if !$zone;
+	my $controllerid = $zone->{controller};
 	next if !$controllerid;
 	my $controller = $controller_cfg->{ids}->{$controllerid};
 	if ($controller) {
 	    my $controller_plugin = PVE::Network::SDN::Controllers::Plugin->lookup($controller->{type});
-	    $controller_plugin->generate_controller_vnet_config($plugin_config, $controller, $transportid, $id, $config);
+	    $controller_plugin->generate_controller_vnet_config($plugin_config, $controller, $zoneid, $id, $config);
 	}
     }
 
diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 012c9a4..5e0a275 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -49,7 +49,7 @@ sub options {
 
 # Plugin implementation
 sub generate_controller_config {
-    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+    my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     my @peers = split(',', $plugin_config->{'peers'}) if $plugin_config->{'peers'};
 
@@ -75,63 +75,63 @@ sub generate_controller_config {
         $is_gateway = 1 if $gatewaynode eq $local_node;
     }
 
-    my @router_config = ();
+    my @controller_config = ();
 
-    push @router_config, "bgp router-id $ifaceip";
-    push @router_config, "no bgp default ipv4-unicast";
-    push @router_config, "coalesce-time 1000";
+    push @controller_config, "bgp router-id $ifaceip";
+    push @controller_config, "no bgp default ipv4-unicast";
+    push @controller_config, "coalesce-time 1000";
 
     foreach my $address (@peers) {
 	next if $address eq $ifaceip;
-	push @router_config, "neighbor $address remote-as $asn";
+	push @controller_config, "neighbor $address remote-as $asn";
     }
 
     if ($is_gateway) {
 	foreach my $address (@gatewaypeers) {
-	    push @router_config, "neighbor $address remote-as external";
+	    push @controller_config, "neighbor $address remote-as external";
 	}
     }
-    push(@{$config->{frr}->{router}->{"bgp $asn"}->{""}}, @router_config);
+    push(@{$config->{frr}->{router}->{"bgp $asn"}->{""}}, @controller_config);
 
-    @router_config = ();
+    @controller_config = ();
     foreach my $address (@peers) {
 	next if $address eq $ifaceip;
-	push @router_config, "neighbor $address activate";
+	push @controller_config, "neighbor $address activate";
     }
-    push @router_config, "advertise-all-vni";
-    push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"l2vpn evpn"}}, @router_config);
+    push @controller_config, "advertise-all-vni";
+    push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"l2vpn evpn"}}, @controller_config);
 
     if ($is_gateway) {
 
-        @router_config = ();
+        @controller_config = ();
         #import /32 routes of evpn network from vrf1 to default vrf (for packet return)
 	foreach my $address (@gatewaypeers) {
-	    push @router_config, "neighbor $address activate";
+	    push @controller_config, "neighbor $address activate";
 	}
-        push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
-        push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv6 unicast"}}, @router_config);
+        push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @controller_config);
+        push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv6 unicast"}}, @controller_config);
 
     }
 
     return $config;
 }
 
-sub generate_controller_transport_config {
-    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+sub generate_controller_zone_config {
+    my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     my $vrf = $id;
     my $vrfvxlan = $plugin_config->{'vrf-vxlan'};
-    my $asn = $router->{asn};
-    my $gatewaynodes = $router->{'gateway-nodes'};
+    my $asn = $controller->{asn};
+    my $gatewaynodes = $controller->{'gateway-nodes'};
 
     return if !$vrf || !$vrfvxlan || !$asn;
 
     #vrf
-    my @router_config = ();
-    push @router_config, "vni $vrfvxlan";
-    push(@{$config->{frr}->{vrf}->{"$vrf"}}, @router_config);
+    my @controller_config = ();
+    push @controller_config, "vni $vrfvxlan";
+    push(@{$config->{frr}->{vrf}->{"$vrf"}}, @controller_config);
 
-    @router_config = ();
+    @controller_config = ();
 
     my $is_gateway = undef;
     my $local_node = PVE::INotify::nodename();
@@ -142,51 +142,49 @@ sub generate_controller_transport_config {
 
     if ($is_gateway) {
 
-	@router_config = ();
+	@controller_config = ();
 	#import /32 routes of evpn network from vrf1 to default vrf (for packet return)
-	#frr 7.1 tag is bugged -> works fine with 7.1 stable branch(20190829-02-g6ba76bbc1)
-	#https://github.com/FRRouting/frr/issues/4905
-	push @router_config, "import vrf $vrf";
-	push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
-	push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv6 unicast"}}, @router_config);
+	push @controller_config, "import vrf $vrf";
+	push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv4 unicast"}}, @controller_config);
+	push(@{$config->{frr}->{router}->{"bgp $asn"}->{"address-family"}->{"ipv6 unicast"}}, @controller_config);
 
-	@router_config = ();
+	@controller_config = ();
 	#redistribute connected to be able to route to local vms on the gateway
-	push @router_config, "redistribute connected";
-	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv4 unicast"}}, @router_config);
-	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv6 unicast"}}, @router_config);
+	push @controller_config, "redistribute connected";
+	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv4 unicast"}}, @controller_config);
+	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"ipv6 unicast"}}, @controller_config);
 
-	@router_config = ();
+	@controller_config = ();
 	#add default originate to announce 0.0.0.0/0 type5 route in evpn
-	push @router_config, "default-originate ipv4";
-	push @router_config, "default-originate ipv6";
-	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, @router_config);
+	push @controller_config, "default-originate ipv4";
+	push @controller_config, "default-originate ipv6";
+	push(@{$config->{frr}->{router}->{"bgp $asn vrf $vrf"}->{"address-family"}->{"l2vpn evpn"}}, @controller_config);
     }
 
     return $config;
 }
 
 sub on_delete_hook {
-    my ($class, $routerid, $sdn_cfg) = @_;
+    my ($class, $controllerid, $zone_cfg) = @_;
 
-    # verify that transport is associated to this router
-    foreach my $id (keys %{$sdn_cfg->{ids}}) {
-        my $sdn = $sdn_cfg->{ids}->{$id};
-        die "router $routerid is used by $id"
-            if (defined($sdn->{router}) && $sdn->{router} eq $routerid);
+    # verify that zone is associated to this controller
+    foreach my $id (keys %{$zone_cfg->{ids}}) {
+        my $zone = $zone_cfg->{ids}->{$id};
+        die "controller $controllerid is used by $id"
+            if (defined($zone->{controller}) && $zone->{controller} eq $controllerid);
     }
 }
 
 sub on_update_hook {
-    my ($class, $routerid, $sdn_cfg) = @_;
+    my ($class, $controllerid, $controller_cfg) = @_;
 
-    # verify that asn is not already used by another router
-    my $asn = $sdn_cfg->{ids}->{$routerid}->{asn};
-    foreach my $id (keys %{$sdn_cfg->{ids}}) {
-	next if $id eq $routerid;
-        my $sdn = $sdn_cfg->{ids}->{$id};
+    # verify that asn is not already used by another controller
+    my $asn = $controller_cfg->{ids}->{$controllerid}->{asn};
+    foreach my $id (keys %{$controller_cfg->{ids}}) {
+	next if $id eq $controllerid;
+        my $controller = $controller_cfg->{ids}->{$id};
         die "asn $asn is already used by $id"
-            if (defined($sdn->{asn}) && $sdn->{asn} eq $asn);
+            if (defined($controller->{asn}) && $controller->{asn} eq $asn);
     }
 }
 
diff --git a/PVE/Network/SDN/Controllers/FaucetPlugin.pm b/PVE/Network/SDN/Controllers/FaucetPlugin.pm
index 38f9abf..dcac6eb 100644
--- a/PVE/Network/SDN/Controllers/FaucetPlugin.pm
+++ b/PVE/Network/SDN/Controllers/FaucetPlugin.pm
@@ -22,28 +22,28 @@ sub properties {
 
 # Plugin implementation
 sub generate_controller_config {
-    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+    my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
 }
 
-sub generate_controller_transport_config {
-    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+sub generate_controller_zone_config {
+    my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     my $dpid = $plugin_config->{'dp-id'};
     my $dphex = printf("%x",$dpid);
 
-    my $transport_config = {
+    my $zone_config = {
 				dp_id => $dphex,
 				hardware => "Open vSwitch",
 			   };
 
-    $config->{faucet}->{dps}->{$id} = $transport_config;
+    $config->{faucet}->{dps}->{$id} = $zone_config;
 
 }
 
 
 sub generate_controller_vnet_config {
-    my ($class, $plugin_config, $controller, $transportid, $vnetid, $config) = @_;
+    my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
 
     my $mac = $plugin_config->{mac};
     my $ipv4 = $plugin_config->{ipv4};
@@ -63,17 +63,7 @@ sub generate_controller_vnet_config {
 
     $config->{faucet}->{vlans}->{$vnetid} = $vlan_config;
 
-    push(@{$config->{faucet}->{routers}->{$transportid}->{vlans}} , $vnetid);
-
-}
-
-sub on_delete_hook {
-    my ($class, $routerid, $sdn_cfg) = @_;
-
-}
-
-sub on_update_hook {
-    my ($class, $routerid, $sdn_cfg) = @_;
+    push(@{$config->{faucet}->{routers}->{$zoneid}->{vlans}} , $vnetid);
 
 }
 
diff --git a/PVE/Network/SDN/Controllers/Plugin.pm b/PVE/Network/SDN/Controllers/Plugin.pm
index 3aed73a..ce35574 100644
--- a/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/PVE/Network/SDN/Controllers/Plugin.pm
@@ -73,13 +73,13 @@ sub generate_sdn_config {
 }
 
 sub generate_controller_config {
-    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+    my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     die "please implement inside plugin";
 }
 
 sub generate_controller_vnet_config {
-    my ($class, $plugin_config, $controller, $transportid, $vnetid, $config) = @_;
+    my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
 
 }
 
@@ -96,13 +96,13 @@ sub controller_reload {
 }
 
 sub on_delete_hook {
-    my ($class, $sndid, $scfg) = @_;
+    my ($class, $controllerid, $zone_cfg) = @_;
 
     # do nothing by default
 }
 
 sub on_update_hook {
-    my ($class, $sdnid, $scfg) = @_;
+    my ($class, $controllerid, $controller_cfg) = @_;
 
     # do nothing by default
 }
diff --git a/PVE/Network/SDN/VnetPlugin.pm b/PVE/Network/SDN/VnetPlugin.pm
index 2da1e1e..d24a539 100644
--- a/PVE/Network/SDN/VnetPlugin.pm
+++ b/PVE/Network/SDN/VnetPlugin.pm
@@ -102,21 +102,21 @@ sub options {
 }
 
 sub on_delete_hook {
-    my ($class, $sdnid, $sdn_cfg) = @_;
+    my ($class, $sdnid, $vnet_cfg) = @_;
 
     return;
 }
 
 sub on_update_hook {
-    my ($class, $sdnid, $sdn_cfg) = @_;
+    my ($class, $vnetid, $vnet_cfg) = @_;
     # verify that tag is not already defined in another vnet
-    if (defined($sdn_cfg->{ids}->{$sdnid}->{tag})) {
-	my $tag = $sdn_cfg->{ids}->{$sdnid}->{tag};
-	foreach my $id (keys %{$sdn_cfg->{ids}}) {
-	    next if $id eq $sdnid;
-	    my $sdn = $sdn_cfg->{ids}->{$id};
-	    if ($sdn->{type} eq 'vnet' && defined($sdn->{tag})) {
-		die "tag $tag already exist in vnet $id" if $tag eq $sdn->{tag};
+    if (defined($vnet_cfg->{ids}->{$vnetid}->{tag})) {
+	my $tag = $vnet_cfg->{ids}->{$vnetid}->{tag};
+	foreach my $id (keys %{$vnet_cfg->{ids}}) {
+	    next if $id eq $vnetid;
+	    my $vnet = $vnet_cfg->{ids}->{$id};
+	    if ($vnet->{type} eq 'vnet' && defined($vnet->{tag})) {
+		die "tag $tag already exist in vnet $id" if $tag eq $vnet->{tag};
 	    }
 	}
     }
diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm
index d7afba1..84ce60c 100644
--- a/PVE/Network/SDN/Zones.pm
+++ b/PVE/Network/SDN/Zones.pm
@@ -75,8 +75,8 @@ sub complete_sdn_zone {
 sub generate_etc_network_config {
 
     my $vnet_cfg = PVE::Cluster::cfs_read_file('sdn/vnets.cfg');
-    my $transport_cfg = PVE::Cluster::cfs_read_file('sdn/zones.cfg');
-    return if !$vnet_cfg && !$transport_cfg;
+    my $zone_cfg = PVE::Cluster::cfs_read_file('sdn/zones.cfg');
+    return if !$vnet_cfg && !$zone_cfg;
 
     #read main config for physical interfaces
     my $current_config_file = "/etc/network/interfaces";
@@ -108,7 +108,7 @@ sub generate_etc_network_config {
 	    next;
 	}
 
-	my $plugin_config = $transport_cfg->{ids}->{$zone};
+	my $plugin_config = $zone_cfg->{ids}->{$zone};
 
 	if (!defined($plugin_config)) {
 	    warn "can't generate vnet $vnet : zone $zone don't exist";
@@ -175,11 +175,11 @@ sub ifquery_check {
 sub status {
 
     my $cluster_vnet_file = "/etc/pve/sdn/vnets.cfg";
-    my $cluster_transport_file = "/etc/pve/sdn/zones.cfg";
+    my $cluster_zone_file = "/etc/pve/sdn/zones.cfg";
     my $local_sdn_file = "/etc/network/interfaces.d/sdn";
     my $err_config = undef;
 
-    return if !-e $cluster_vnet_file && !-e $cluster_transport_file;
+    return if !-e $cluster_vnet_file && !-e $cluster_zone_file;
 
     if (!-e $local_sdn_file) {
 
@@ -188,10 +188,10 @@ sub status {
     } else {
 	# fixme : use some kind of versioning info?
 	my $cluster_vnet_timestamp = (stat($cluster_vnet_file))[9];
-	my $cluster_transport_timestamp = (stat($cluster_transport_file))[9];
+	my $cluster_zone_timestamp = (stat($cluster_zone_file))[9];
 	my $local_sdn_timestamp = (stat($local_sdn_file))[9];
 
-	if ($local_sdn_timestamp < $cluster_vnet_timestamp || $local_sdn_timestamp < $cluster_transport_timestamp) {
+	if ($local_sdn_timestamp < $cluster_vnet_timestamp || $local_sdn_timestamp < $cluster_zone_timestamp) {
 	    $err_config = "local sdn network configuration is too old, please reload";
 	    warn $err_config;
         }
@@ -204,19 +204,19 @@ sub status {
     my $nodename = PVE::INotify::nodename();
 
     my $vnet_status = {};
-    my $transport_status = {};
+    my $zone_status = {};
 
     foreach my $id (keys %{$vnet_cfg->{ids}}) {
 	my $zone = $vnet_cfg->{ids}->{$id}->{zone};
 	next if defined($zone_cfg->{ids}->{$zone}->{nodes}) && !$zone_cfg->{ids}->{$zone}->{nodes}->{$nodename};
 
 	$vnet_status->{$id}->{zone} = $zone;
-	$transport_status->{$zone}->{status} = 'available' if !defined($transport_status->{$zone}->{status});
+	$zone_status->{$zone}->{status} = 'available' if !defined($zone_status->{$zone}->{status});
 
 	if($err_config) {
 	    $vnet_status->{$id}->{status} = 'pending';
 	    $vnet_status->{$id}->{statusmsg} = $err_config;
-	    $transport_status->{$zone}->{status} = 'pending';
+	    $zone_status->{$zone}->{status} = 'pending';
 	} elsif ($status->{$id}->{status} && $status->{$id}->{status} eq 'pass') {
 	    $vnet_status->{$id}->{status} = 'available';
 	    my $bridgeport = $status->{$id}->{config}->{'bridge-ports'};
@@ -224,15 +224,15 @@ sub status {
 	    if ($status->{$bridgeport}->{status} && $status->{$bridgeport}->{status} ne 'pass') {
 		$vnet_status->{$id}->{status} = 'error';
 		$vnet_status->{$id}->{statusmsg} = 'configuration not fully applied';
-		$transport_status->{$zone}->{status} = 'error';
+		$zone_status->{$zone}->{status} = 'error';
 	    }
 	} else {
 	    $vnet_status->{$id}->{status} = 'error';
 	    $vnet_status->{$id}->{statusmsg} = 'missing';
-	    $transport_status->{$zone}->{status} = 'error';
+	    $zone_status->{$zone}->{status} = 'error';
 	}
     }
-    return($transport_status, $vnet_status);
+    return($zone_status, $vnet_status);
 }
 
 1;
diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm
index 3204d69..5d9aeff 100644
--- a/PVE/Network/SDN/Zones/Plugin.pm
+++ b/PVE/Network/SDN/Zones/Plugin.pm
@@ -102,13 +102,13 @@ sub generate_sdn_config {
 }
 
 sub generate_controller_config {
-    my ($class, $plugin_config, $router, $id, $uplinks, $config) = @_;
+    my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
     die "please implement inside plugin";
 }
 
 sub generate_controller_vnet_config {
-    my ($class, $plugin_config, $controller, $transportid, $vnetid, $config) = @_;
+    my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
 
 }
 
@@ -125,9 +125,14 @@ sub controller_reload {
 }
 
 sub on_delete_hook {
-    my ($class, $sndid, $scfg) = @_;
+    my ($class, $zoneid, $vnet_cfg) = @_;
 
-    # do nothing by default
+    # verify that no vnet are associated to this zone
+    foreach my $id (keys %{$vnet_cfg->{ids}}) {
+	my $vnet = $vnet_cfg->{ids}->{$id};
+	die "zone $zoneid is used by vnet $id"
+	    if ($vnet->{type} eq 'vnet' && defined($vnet->{zone}) && $vnet->{zone} eq $zoneid);
+    }
 }
 
 sub on_update_hook {
diff --git a/PVE/Network/SDN/Zones/QinQPlugin.pm b/PVE/Network/SDN/Zones/QinQPlugin.pm
index c9f522b..2036620 100644
--- a/PVE/Network/SDN/Zones/QinQPlugin.pm
+++ b/PVE/Network/SDN/Zones/QinQPlugin.pm
@@ -41,18 +41,18 @@ sub generate_sdn_config {
     my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks, $config) = @_;
 
     my $tag = $vnet->{tag};
-    my $transport_tag = $plugin_config->{tag};
+    my $zone_tag = $plugin_config->{tag};
     my $mtu = $vnet->{mtu};
     my $alias = $vnet->{alias};
     my $vlanprotocol = $plugin_config->{'vlan-protocol'};
     my $uplink = $plugin_config->{'uplink-id'};
 
     die "missing vlan tag" if !$tag;
-    die "missing transport vlan tag" if !$transport_tag;
+    die "missing zone vlan tag" if !$zone_tag;
 
     my $iface = $uplinks->{$uplink}->{name};
     $iface = "uplink${uplink}" if !$iface;
-    $iface .= ".$transport_tag";
+    $iface .= ".$zone_tag";
 
     #tagged interface
     my @iface_config = ();
diff --git a/PVE/Network/SDN/Zones/VlanPlugin.pm b/PVE/Network/SDN/Zones/VlanPlugin.pm
index 2dd65e9..8f957f3 100644
--- a/PVE/Network/SDN/Zones/VlanPlugin.pm
+++ b/PVE/Network/SDN/Zones/VlanPlugin.pm
@@ -69,17 +69,6 @@ sub generate_sdn_config {
     return $config;
 }
 
-sub on_delete_hook {
-    my ($class, $transportid, $sdn_cfg) = @_;
-
-    # verify that no vnet are associated to this transport
-    foreach my $id (keys %{$sdn_cfg->{ids}}) {
-	my $sdn = $sdn_cfg->{ids}->{$id};
-	die "transport $transportid is used by vnet $id"
-	    if ($sdn->{type} eq 'vnet' && defined($sdn->{zone}) && $sdn->{zone} eq $transportid);
-    }
-}
-
 1;
 
 
diff --git a/PVE/Network/SDN/Zones/VxlanPlugin.pm b/PVE/Network/SDN/Zones/VxlanPlugin.pm
index 8a39921..956c950 100644
--- a/PVE/Network/SDN/Zones/VxlanPlugin.pm
+++ b/PVE/Network/SDN/Zones/VxlanPlugin.pm
@@ -123,17 +123,6 @@ sub generate_sdn_config {
     return $config;
 }
 
-sub on_delete_hook {
-    my ($class, $transportid, $sdn_cfg) = @_;
-
-    # verify that no vnet are associated to this transport
-    foreach my $id (keys %{$sdn_cfg->{ids}}) {
-	my $sdn = $sdn_cfg->{ids}->{$id};
-	die "transport $transportid is used by vnet $id"
-	    if ($sdn->{type} eq 'vnet' && defined($sdn->{zone}) && $sdn->{zone} eq $transportid);
-    }
-}
-
 1;
 
 
-- 
2.20.1




More information about the pve-devel mailing list